Description
Hash-Map Word Count Project
cs 2420
Purpose
To gain experience designing, implementing, and using a Hash-Map.
Overview
You are to design the Hash-Map portion of a word-frequency count application. The app will open the AlicelnWonderland.txt file (provided)
(the code in mainO assumes it to be in “default” location. For Visual Studio, this is where the source files are) and parse the individual words
from that file. Each word will be added to the Hash-Map with the GetKeyVaIueO and SetKeyValue() member functions. The text word will be
the ‘key”. Initially, that key will not be in the map, so SetKeyVaIue O will add it to the map and set its initial count to 1 . Subsequently, when
the same key is processed, GetkeyVaIue() will tell what the current count is and then a call to SetKeyVaIueO will increment the count by one.
Once the entire text of Alice In Wonderland has been added to the map, the 1 5 most frequently occurring words will be found and displayed.
The FindLargestWordCount() function in Main.cpp will do this, but it will need to iterate over all keys in the map to find the one with the
largest value. You will have to provide an external fteratorto assist in this. The HashMap class has both a begin() and an end() function
which return Iterators, similar to your external iterator project
Your Part
You will have to write:
• Iterator.cpp
• HashMap.cpp
Note that the header information for Iterator.cpp is found at the top of HashMap.h. This is because the iterator is closely associated with
the HashMap.
You must NOT modify the code in Main.cpp; it is the driver to test the app.
Please include your header information (standard name, section, date, project, honesty statement, etc) at the beginning of BOTH
Iterator.cpp and HashMap.cpp.
Hints
The Hash-Map must use a “Chained-Hashing” approach (text section 12.3). The base array is dynamically allocated and is of size 500. The
constructor for HashMap will need to dynamically allocate this array and then initialize every entry to a nullptr.
hashArray = new Node* [size];
for (int i
C; i < size; i++)
hashAr ray ]
nullptr;
sizeCfArray = size;
You MUST implement a destructor for the HashMap. It will need to loop through the entire array and for every non-nullptr entry, delete each
Node in the linked list. Once all the nodes have been deleted, you will have to also delete the dynamic array.
The Iterator part is somewhat tricky as well. Try to visualize on a white-board how the map is iterated. If you cant do it on a white-board,
you will not be able to implement it.