Question: C++ Write a class named HashTable that implements a hash table using linear probing to resolve collisions. Submit your solution in it's own header file
C++
Write a class named HashTable that implements a hash table using linear probing to resolve collisions.
Submit your solution in it's own header file named HashTable.h.
Your solution should include the following methods in it's public interface:
insert() - accepts a string as it's only argument, which is added to the hash table, setting the element's mark where it is stored to 2.
remove() - accepts a string as it's only argument, and removes the string from the hash table (if found) by setting it's mark to 1.
isFull() - returns true if the hash table is full, false otherwise.
isEmpty() - returns true if the hash table is full, false otherwise.
find() - accepts a string as it's only argument. Returns true if it is found in the hash table, false otherwise.
clear() - empties the hash table by setting each elements mark to 0.
print() - displays the contents of the hash table to the screen.
constructor - accepts an integer as it's only argument, creating a hash table that can store that many values (a dynamically allocated array of Elements).
destructor - frees all memory used.
Other than the print() method, none of these methods should interact with the user in any way.
Here's a list of private attributes:
Element - a nested struct containing the following fields:
key - Stores the string passed to the object through the insert method.
mark - an variable set to 2 if the element is being used, 1 if it was used but then was deleted, and 0 if it was never used.
table - an Element pointer that holds the memory address of a dynamically allocated array of Elements.
size - stores the size of the Element array.
hash - The hash function. It accepts a String as it's only argument and returns an index into the hash table. Use the sum of ascii values approach.
DRIVER
#include "HashTable.h" int main() { HashTable h(5); cout Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
