简体   繁体   English

霍夫曼树的主张?

[英]Claim of Huffman Tree?

I saw the following claim:我看到了以下声明:

Given Q={1,2,...,n} , and positive frequency function f such that:给定Q={1,2,...,n}和正频率 function f使得:

f(1) > f(2) >... > f(n) > f(1)/3 , f(1) > f(2) >... > f(n) > f(1)/3 ,

Then there are leafs at maximum 3 different levels of Huffman tree.然后在霍夫曼树的最多 3 个不同级别上有叶子。

I have been looking for a counterexample but no luck, can someone help me?我一直在寻找一个反例,但没有运气,有人可以帮助我吗?

Assume that the claim is false for some tree, with shallowest leaf at depth H. The shallowest leaf will have frequency f(1).假设某棵树的声明是错误的,在深度 H 处具有最浅的叶子。最浅的叶子的频率为 f(1)。

Since the tree extends to depth at least H+3, then there must be a subtree at depth H+1 with at least 3 leaves.由于树的深度至少为 H+3,因此在深度 H+1 处必须有一个至少有 3 个叶子的子树。 The smallest possible subtree that gets to H+3 is shaped like:到达 H+3 的最小可能子树的形状如下:

   O
  / \
 O   O
    / \
   O   O

The total frequency of the subtree is more than f(1), the frequency of the shallowest leaf, and yet it occurs at a deeper level.子树的总频率大于 f(1),即最浅叶的频率,但它发生在更深的层次。 We could therefore improve the Huffman tree by swapping the positions of this subtree and the shallowest leaf.因此,我们可以通过交换这个子树和最浅叶的位置来改进霍夫曼树。

Since Huffman trees are proven to be optimal, this can't happen, so the claim must be true.由于霍夫曼树被证明是最优的,这不可能发生,所以这个说法一定是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM