Skip to content
Dr Jack HW Helper
Home
Browse
About
Contact
Academic Integrity
T
Academic Integrity:
tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.
Home
Browse
N
Need help on the Trend File Output section as well as the main code. Last two pi
Need help on the Trend File Output section as well as the main code. Last two pi
ID:
3687570
• Letter:
N
Question
Need help on the Trend File Output section as well as the main code. Last two pictures are the correct hashtag.cpp file.
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
Related Questions
Need help on my assignment. INSTRUCTIONS For your second graded project, write a
Question #3867153
Need help on my assignment. Instructions: Go online and look up different B2B co
Question #2246861
Need help on my assignment. Instructions: Go online and look up different B2B co
Question #2246862
Need help on my assignment. Instructions: Go online and look up different B2B co
Question #2246864
Need help on my assignment. Instructions: Use your cell phone as the basis for t
Question #3868115
Need help on my assignment. It needs to be five to ten sentences each. 1. Descri
Question #3889520
Need help on my assignment. It needs to be one or two paragraphs each. 1. Name t
Question #3870236
Need help on my assignment: Procedure: Go online and look up different B2B compa
Question #2246911
Navigate
Browse (All)
Browse N
Subjects
Previous
Need help on the Trend File Output Section. Last two pictures are the hashtag.cp
Next
Need help on the Trend File Output section which is the c and h file as well as