Implemented Huffman encoding.