Huffman Tree based compression

Huffman tree is used to generate variable length binary codes for every character that appears in a message. Usually in a very long message different characters appear with different frequency and this property is used to generate the Huffman codes for every character that appears in the message. The problem is to use the Huffman tree to encode the alphabets that appear in the given text file and then encode the input file using the Huffman codes generated by the tree. Compare this encoded file size with the input file size and then decode the file back to the original file.

 

Use a simple text file to test your code.

 

For more details, mail to sunando@cse.iitm.ernet.in