The goal of this lab is to implement the Huffman Tree Encoding. Some of the skills you will practice in this lab are:
You are free to create the design to solve this problem. The general steps for this program are:
Open the file for input and create the Frequency Table. This table counts the occurrences of each character in the file.
Sort the Frequency Table on frequency. To sort the table use the following comparison:
if (tableElement1.frequency == tableElement2.frequency) return tableElement1.element > tableElement2.element; else return tableElement1.frequency > tableElement2.frequency;
Basically, by using that comparison, you will be sorting your Frequency Table first by frequency and then by element. Example:
Before Sorting
After Sorting
Notice that b and c have the same frequency, since we are sorting first by frequency and then by element, c ends up higher in the table as it is greater than b.
Using the Frequency Table create the Huffman Tree from bottom up.
Once the tree is created, traverse it to create the code for each of the symbols (characters) found in the file. This will result in a Encoding Table.
Using the Encoding Table read the input file, and for each character use the table to get the encoding and write the encoding into the output file.
You are given sixteen files:
test-file-0.txt
test-file-0.table
test-file-0.encoded
test-file-0.frequency
test-file-1.txt
test-file-1.table
test-file-1.encoded
test-file-1.frequency
test-file-2.txt
test-file-2.table
test-file-2.encoded
test-file-2.frequency
test-file-3.txt
test-file-3.table
test-file-3.encoded
test-file-3.frequency
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here