小编tim*_*tim的帖子

在 zlib 中,当字母表的霍夫曼代码长度超过最大代码长度(15)时会发生什么?

https://www.rfc-editor.org/rfc/rfc1951

Note that in the "deflate" format, the Huffman codes for the
     various alphabets must not exceed certain maximum code lengths.
Run Code Online (Sandbox Code Playgroud)

最大代码长度定义为 15。

当霍夫曼码长度超过15时会发生什么?

来自https://cs.stackexchange.com/questions/75542/maximum-size-of-huffman-codes-for-an-alphabet-containing-256-letters 256 个符号字母表的最大可能代码大小是 256 位。考虑以下情况:最频繁的符号的频率为 1/2,下一个最频繁的符号的频率为 1/4,然后是 1/8

因此,在文字/长度字母表中,最大霍夫曼代码长度为 285-1=284,但在 zlib 中,最大代码长度为 15。

  1. 为什么选择 15 作为最大代码长度?
  2. 如果代码长度超过15,zlib会失败吗?

zlib huffman-code

2
推荐指数
1
解决办法
746
查看次数

标签 统计

huffman-code ×1

zlib ×1