How to run:
-
python HuffmanCompress.py InputFile OutputFile
-
python HuffmanDecompress.py InputFile OutputFile
Ex: python HuffmanCompress test1.txt compress1.txt
And let's see what we've defined for a tree inneed:
Ref: https://en.wikipedia.org/wiki/Huffman_coding
- Huffman code tree: contain Node, InternalNode, and Leaf, represent a Huffman code tree. The leaves represent symbols. The path to a leaf represents the bit string of its Huffman code.
Ref: https://en.wikipedia.org/wiki/Canonical_Huffman_code
- Converts an arbitrary CodeTree to a canonical code.
- IO Stream solution: