Write a C++ program that builds and maintains a stack of open-addressing Hash ta
ID: 3774839 • Letter: W
Question
Write a C++ program that builds and maintains a stack of open-addressing Hash tables. Your program will read commands from standard input (cin) and “execute” those commands to maintain a stack of hashtables as well as insert and search the hashtable stack. The following commands are ones that will be used in the data file. • Push – push a new Hashtable onto the stack of hashtables • Pop – remove the Hashtable that is on the top of the stack • Insert (int key) – insert the value “key” into the hashtable at the top of the stack • int Search (int key) – search for the value “key” in the hashtable at the top of the stack. Returns the integer index of either o Where the key was found (success) or o Where the search we determined to be unsuccessful • int Find (int key) – Starting a the top of the stack, search for key in the hashtable at the top of the stack and if key is not found there move “down” the stack until either key is found (success) or the entire stack has been searched. Program Details Write your program in C++. Your program should include at least two C++ classes. (I’d recommend more.) Output • Each insert, search and find command should print a line of output showing what index was returned (by search and find) and whether the search/insert/find was successful or unsuccessful. Something like: The search for 1023 was successful and returned index 19. Similar messages should be printed for each insert and find.
Explanation / Answer
#include using std::string; struct Entry { bool is_in_use; string value; }; // Return a number computed from the bits of the characters in the string s. unsigned int hash_string(const string& s) { unsigned int h = 0; for (size_t i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.