哈尔曼夫树以及前缀编码

题目1:

The Huffman code is one kind of optimal prefix codes. For a given alphabet and its characters' frequencies,the Huffman codes may not be unique, but the Huffman code length of each character is unique. (错)

前缀编码可以不一样&&可以一样0,树的形态可以不一样&&可以一样,对于不同的字符的二进制编码长度可以不一样&&可以一样(比如a:0001 ,b:1111.长度都是4)

 

题目2:

Given a Huffman tree for N (≥2) characters, all with different weights. The weight of any non-leaf node must be no less than the weight of any node on the next lower level.

意思说非叶节点的节点他的权重值肯定大于或者等于他下一层节点的权值。这是对的 。

因为构建哈尔曼夫树的时候是采用贪心算法,每次选取根节点最小的树分别作为左右子树,新的根节点权值为这两个左右子树根节点权值之和。

posted @ 2022-12-11 23:52  noob-lian  阅读(45)  评论(0)    收藏  举报
Language: