added alternative code for construction huffman shaped wavelet tree