针对同一哈夫曼树有多种不同哈夫曼编码的问题,提出一种哈夫曼编码的选择算法。算法以哈夫曼编码的多样性为基础,在哈夫曼树的非叶子节点处提供编码方式0或1,由所有非叶子节点的编码方式组成一个二进制序列,最后根据该二进制序列进行节点的哈夫曼编码。鉴于哈夫曼编码的递归子结构,设计了一种不同于传统哈夫曼编码的回溯算法。算例仿真表明,一方面同一事件有时可以构造不同的哈夫曼树,另一方面同一哈夫曼树根据编码方式的不同可以得到不同的哈夫曼编码结果。
Aiming at the same Huffman tree having a variety of different Huffman coding,this paper proposes a Huffman code selection algorithm. Based on diversity of Huffman coding,the algorithm provides 0 or 1 as coding method for every non leaf node of the huffman tree. A binary sequence is constructed by the composition of all non leaf node coding method,finally Huffman coding is obtained according to the binary sequence. In view of the fact that the recursive substructures of Huffman coding,this paper designs a backtracking algorithm that is different from the traditional Huffman coding. Simulation results show,on the one hand,sometimes the same event can contruct different Huffman tree. on the other hand according to the different coding methods different results of Huffman coding can obtained from the same Huffman tree.