Project Details

The first part of this project was reading the input file and storing all the Chars into a FrequencyTable data structure. From there, I turned each index in my FrequencyTable into a Node that had the Char element and its respective frequency stored inside. Then, I put all the newly created Nodes into a priority_queue data structure that stored sorted them from least to greatest in terms of frequency. Using this priority_queue, I created my Tree by popping Nodes one by one and placing them in the Tree. Once the Tree was created I was able to assign each Node a code that represented its location in the tree. The codes assigned with each Node in the tree allowed me to repeatedly traverse the tree to rebuild the original file, but instead of using Chars, I used the respective code for each Node.