added alternative huffman tree construction code