Huffman encoding implemenation