Hash-Map Word Count Project solution




To gain experience designing, implementing, and using a Hash-Map.


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”locatlon. 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 GetKeyValueO and SetKeyValueO member functions. The text word will be

the “key”. Initially, that key will not be in the map. so SetKeyValue 0 will add it to the map and set its Initial count to 1. Subsequently, when

the same key is processed. GetkeyValueO will tell what the current count is andthen a call to SetKeyValueO will increment the count by one.

Once the entire text of Alice In Wonderland has been added to the map, the 15 most frequently occurring words will be found and displayed. The FindlargestWordCountO function in Main.cpp will do this, butit 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 iterator to assist in this. The HashMap class has both a beginO and an endO 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.


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>\[sizej ;

fer (int i = D; i < size; i++)

hashArray [i J = nullptr;

sizeOfArray = 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 can’t do it on a white-board, you will not be able to implement It.