Attached is a sample Huffman Tree and Binary Tree class. The Huffman Tree contains a main method as a tester class to show the encoded values, and also a sample decoding. The Huffman Tree utilizes the BinaryTree class and PriorityQueue.random notes:
String data are the symbols being coded
Double array weight is the weight assigned to each symbol, currently showing 1 to a, 2 to b, ..etc.
The higher the weight the shorter the Huffman encoding
printCode method shows this
decode method translates 0's and 1's to symbols encoded
need BinaryTree and HuffmanTree in same package.
Java Programming >