implementation of Huffman coding algorithm