Question
Please use C++ language. please complete the below from this code. A through N.
The goal of the following assignment is to analyze and implement legacy code in the context of Hash Map Chaining and Singly Linked Lists implementation.
Define:
Hashmap Key Collisions-
Helpful Video Hashing and Collisions
Hashmap Chaining-
LAB ASSIGNMENT
Complete Table Below:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
A
B
C
D
E
F
G
H
I
J
K
L
M
N
class LinkedHashEntry private int key: int value Linked HashEntry next: public Linked HashEntry (int key int value n this key key this value value this next int getKey return key: int getValue return value: void setValue int value this value value LinkedHashEntry getNext return next void setNext (LinkedHashEntry next) this next const int TABLE SIZE 128 class HashMap private Linked HashEntry table public HashMap table new LinkedHashEntr tTABLE-SIZEl: for int i 0: i TABLE SI2E: it table Di NULL: int get (int key) int hash key t TABLE SIZE if (table hash NULL) return -1 else LinkedHashEn entry tab while entry NULL & 6 entry->getKey entry entry->getNext if (entry NULL) return -1; else return entry->getValue
Explanation / Answer
#include #include #include #include using namespace std; const int TABLE_SIZE = 128; /* * HashNode Class Declaration */ class HashNode { public: . int key; int value; HashNode* next; HashNode(int key, int value) { this->key = key; this->value = value; this->next = NULL; } }; /* * HashMap Class Declaration */ class HashMap { private: HashNode** htable; public: HashMap() { htable = new HashNode*[TABLE_SIZE]; for (int i = 0; i next; } if (entry == NULL) { entry = new HashNode(key, value); if (prev == NULL) { htable[hash_val] = entry; } else { prev->next = entry; } } else { entry->value = value; } } /* * Remove Element at a key */ void Remove(int key) { int hash_val = HashFunc(key); HashNode* entry = htable[hash_val]; HashNode* prev = NULL; if (entry == NULL || entry->key != key) { cout