IST238: Algorithms. Project #5.
This project is dedicated to implementation of the Huffman compression algorithm.
It will include several parts:
- Implement priority queue template class PQueue with the following public methods:
- default constructor PQueue() and constructor that allows to specify the amount of memory allocated for the
queue PQueue(int N)
- destructor ~PQueue()
- method void (Node node) that adds an item to the queue
- method Node get_top() that returns the highest priority item and removes it from the queue
- Boolean method bool empty() that returns true if the queue is empty and false
otherwise
- method int Size() that returns the current size of the queue
Note: you should use the heap structure to implement this class.
- Implement the Huffman code to construct the optimal prefix tree. To complete this, you need:
- read all characters from the specified file
- count their frequencies
- create the as many nodes of the type Node as you have read distinct characters
- run the Huffman's algorithm to construct the optimal prefix tree
- based on the prefix tree build the coding table that specifies variable length code for each character from the file
- Re-read the file and print the sequence of zeros and ones corresponding to the file contents. The coded version of the
text should be written in another file.
- Read the newly created "compressed" file and decode it using the prefix tree. Print the text on the screen.