Implementation of the Huffman compression algorithm, Dynamic Version