Question: Your tasks Review all of the provided code, and make sure that you understand it . Add a constructor that takes the size of the
Your tasks
Review all of the provided code, and make sure that you understand it
Add a constructor that takes the size of the hash table as its only parameter and
initializes the hash table accordingly. It should throw an IllegalArgumentException if
the size is not positive.
Implement each method from the HashTable interface as efficiently as possible. Make
sure that each of these methods has the same basic functionality as the corresponding
method from the OpenHashTable class discussed in lecture. In particular, they should
throw exceptions for the same reasons that the OpenHashTable methods do
As you add or remove items from the table, make sure that you update numKeys
accordingly.
Because a given chain can grow to an arbitrary length, the hash table will never overflow,
and thus your insert method can always return true.
For example, if you run this test code:
you should see:
true
apple; howdy null, null, goodbye null
Note that:
Position has a chain with two keys, because both "howdy" and "apple" are
assigned a hash code of by h when the table size is
Position has a chain with one key, because "goodbye" is assigned a hash code of
by when the table size is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
