Question: In c + + This project is designed to help students to understand the HashTable and algorithms related to HashTable. The students need to implement

In c++
This project is designed to help students to understand the HashTable and algorithms related to HashTable. The students need to implement two given classes: MyHashEntry and MyHashTable.
Three classes are given. The students shall not modify the CSCI251ProjThree.cpp file. However, the students should understand this file. The other file, MyHashTable.h, are the file that the students need to finish.
This file MyHashTable.h, must be implemented with in the given design. The students cannot change the name of public methods. Please notice that the table must be implemented as generic data structure.
/*
*CSCI251ProjThree.cpp
*CSCI251ProjThree. It is an interactive file for MyHash Table
*
* @author Mike Mireku Kwakye
* @version October 9,2024
*/
#include
#include
#include "MyHashTable.h"
using namespace std;
void menu(); // print out the menu
int main(){
string value;
string key;
int choice;
MyHashTable table;
do{
menu();
cout << "Enter your choice:
";
cin >> choice;
switch(choice){
case 1:
cout << "Enter an (Key, Value) pair that you will add to table
";
cout << "Separate by white space: ";
cin >> key;
cin >> value;
table.insert(key, value);
cout <<"("<< key <<","<< value <<") entered
";
break;
case 2:
cout << "Enter a key that you will remove from table:
";
cin >> key;
value = table.remove(key);
if(value.empty())
cout << "Remove successfully. The removed value is "<< value;
else
cout <<"No such key in table";
break;
case 3:
cout << "Enter the key that you want to search for: ";
cin >> key;
value = table.get(key);
if(value.empty())
cout <<"No such data in table
";
else
cout << "The corresponding value is: "<< value << endl;
break;
case 4:
if(table.isEmpty())
cout << "table is empty
";
else
printTable(table);
break;
case 5:
cout << "Make sure you run enough test before you turn it in
";
break;
default:
cout << "Wrong option. Please choose from menu
";
break;
}
}while(choice !=5);
}
void menu(){
cout <<"********************************"<< endl;
cout <<"*MENU *"<< endl;
cout <<"*1. Add a (key, value) pair *"<< endl;
cout <<"*2. Remove a value by its key *"<< endl;
cout <<"*3. Search a value by its key *"<< endl;
cout <<"*4. Print out hash table *"<< endl;
cout <<"*5. Quit *"<< endl;
cout <<"********************************"<< endl;
}
/*
* MyHashTable.h
* CSCI251ProjThree - A simple HashTable. Collision handling is by Chaining
*
* @author Your Name
* @version Date
*/
#include
using namespace std;
#ifndef MyHashTable_h
#define MyHashTable_h
template
struct MyHashEntry{
K key;
V value;
MyHashEntry* next;
};
template
class MyHashTable{
public:
template

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 Programming Questions!