implement building Huffman tree for week 4 assignment