Question: Hash Table -table: List* -size: int -hash (key : string) : int {query} +Hash Table(s : int) : +~Hash Table() : +clear() : void +insert(key

Hash Table

-table: List* -size: int

-hash (key : string) : int {query} +Hash Table(s : int) : +~Hash Table() : +clear() : void +insert(key : string) : int +find (key :string) : bool +isFull() : bool {query} +isEmpty() : bool {query} +remove (key:string) : int +print() : void {query}

Use the above UML diagram and descriptions below to write a class that implements a Hash table. Your implementation should use open chaining to resolve collisions. You may provide additional class attributes, as you see fit, to complete the class.

The above class has the following private attributes:

table: This is a pointer to the object's dynamically allocated hash table. Used to create an array of Linked List objects.

size - stores the number of elements in the hash table ( the capacity ).

hash - the hash function. It accepts the key string and returns the hash value.

The class has the following public attributes:

constructor - accepts an integer argument used to determine the number of elements in the hash table. Dynamically allocates the hash table.

destructor - deallocates all dynamically allocated memory.

insert - insert's it's argument into the hash table. calls the hash function to obtain an appropriate hash address. Returns 0 if successful, -1 otherwise.

remove - removes the first key matching it's argument from the hash table. Returns 0 if successful, -1 otherwise.

find - returns true if a key matching it's argument is found, false otherwise.

clear - resets the object to it's initial state.

isFull - returns true if the structure is full, false otherwise.

isEmpty - returns true if the structure has no keys, false otherwise.

print - displays all the keys currently stored in the structure. PLEASE NOTE: FOLLOW AND USE THE ABOVE UML DIAGRAM (That includes function names as well) !! The class along with its function prototypes and its definitions should all be contained INSIDE THE HEADER FILE !! YOUR ANSWER SHOULD BE A HEADER FILE WITH THE CLASS DECLARATION, FUNCTION PROTOTYPE, AND FUNCTION DEFINITIONS !!! DO NOT MAKE A .CPP PROGRAM !!!

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!