Starting from:

$25

  CSD235335 - Assignment 4 - Hash Tables - Solved

     Programming Assignment 4 - Hash Tables


 

Hash Tables
For this assignment you will implement a hash table that meets the following requirements:

  the underlying data structure, hashArray, is a fixed size Java array (not an ArrayList) of type Integer

(not int)

 

methods:

 HashTable( int sz )  //a constructor that takes a single int parameter void insert(Integer key)  //takes an Integer parameter and stores it in the list void remove(Integer key)  // find an item in the hash table and remove it

Integer search(Integer key)  // searches for an item in the hash table and if found, return it. Otherwise, return null void toString()  // outputs the contents of the hash table, one row per element in hashArray int size()  // return the number of elements in all of the chains int size(int index) // return the number of elements in the indexed chain double loadFactor()  // a method the calculates and returns the loading factor to the caller

 and the following private method(s):

rehash() - instantiate an Integer array that is the next prime number greater than twice the size of the original hash array.  Then for each element in the original hash array, rehash it into new array

(don't forget that the hash function is based  on the size of the hash array)

                                                               

More products