Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the code in C++. Create a class called Hashtable. The hash table should su

ID: 3575123 • Letter: W

Question

Write the code in C++. Create a class called Hashtable. The hash table should support inserting and deleting values. Determine whether we could create anagrams of the following phrases to create palindromes using the created Hashtable class.

Example: An anagram of "Coat Act" is "Taco Cat" which is a palindrome.

In your main, test the following phrases:

1. Acre Arc

2. Cents Seen

3. Woodenware Waterworn Nada

4. Nonfederated Downtowner Narrowed Rawn Ware Waw Aw

5. Nonbarbiturate Tantamount Mime Meet

6. Campana Napalm Alan An Aa

7. Cord Um Nun

8. Theta Pigs

9. A Cacao Wistaria Straw

Explanation / Answer

#include #include #include using namespace std; const int TABLE_SIZE = 5; /* * HashNode Class Declaration */ class HashNode { public: int key; int value; HashNode(int key, int value) { this->key = key; this->value = value; } }; /* * DeletedNode Class Declaration */ class DeletedNode:public HashNode { private: static DeletedNode *entry; DeletedNode():HashNode(-1, -1) {} public: static DeletedNode *getNode() { if (entry == NULL) entry = new DeletedNode(); return entry; } }; DeletedNode *DeletedNode::entry = NULL; /* * HashMap Class Declaration */ class HashMap { private: HashNode **htable; public: HashMap() { htable = new HashNode* [TABLE_SIZE]; for (int i = 0; i key == key) htable[hash_val]->value = value; } } else htable[hash_val] = new HashNode(key, value); } } /* * Search Element at a key */ int Search(int key) { int hash_val = HashFunc(key); int init = -1; while (hash_val != init && (htable[hash_val] == DeletedNode::getNode() || htable[hash_val] != NULL && htable[hash_val]->key != key)) { if (init == -1) init = hash_val; hash_val = HashFunc(hash_val + 1); } if (htable[hash_val] == NULL || hash_val == init) return -1; else return htable[hash_val]->value; } /* * Remove Element at a key */ void Remove(int key) { int hash_val = HashFunc(key); int init = -1; while (hash_val != init && (htable[hash_val] == DeletedNode::getNode() || htable[hash_val] != NULL && htable[hash_val]->key != key)) { if (init == -1) init = hash_val; hash_val = HashFunc(hash_val + 1); } if (hash_val != init && htable[hash_val] != NULL) { delete htable[hash_val]; htable[hash_val] = DeletedNode::getNode(); } } }; /* * Main Contains Menu */ int main() { HashMap hash; int key, value; int choice; while(1) { cout