【发布时间】:2019-07-15 09:14:20
【问题描述】:
在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.
最大代码长度定义为 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。
- 为什么选择 15 作为最大代码长度?
- 如果代码长度超过 15,zlib 会失败吗?
【问题讨论】:
标签: zlib huffman-code