Question: topic: Hash Table In this assignment, you implement a hash table using chained hashing. The hash table size is determined at initialization time and never

topic: Hash Table

In this assignment, you implement a hash table using chained hashing. The hash table size is determined at initialization time and never changes. Each hash table entry is a linked list, so each hash table entry can hold any number of values. You may use a linked list from the Java API, or one from one of your previous assignments.

Your hash table must be designed to map keys to values. None of the keys or values are allowed to be null. Keys are compared using the .equals method.

Your hash table should use the hashCode() method to compute the hash for a given string. Use Math.abs to turn that into a positive value, and modulo to make it into an array index (this description is not quite enough, so you will have to figure out exactly how to make this work).

Your hash table class (called Hash211) must provide the following methods:

 Hash211(int capacity, boolean printTimes); // constructor V put(K key, V value); // add or replace a Key,Value V get(Object key); // return a value for the given key 

Each of these functions is described in more detail here.

The second parameter to the constructor specifies whether your code should print out the time (in nanoseconds) for each call to put and get. To do this, you may re-use your code from Assignment. Since executing any print statements substantially increases the runtime, when printTimes is false, your code may run considerably faster.

Analysis and measurement

You should analyze and measure the runtime of your hash table put and get operations in two cases:

When the hash table size s is much larger (at least 10 times larger) than the number n of elements added.

When the hash table size s is much less (at least 10 times less) than the number n of elements added.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!