Valid Huffman Codes?

霸气de小男生 提交于 2019-12-02 03:42:47

No. A Huffman code is a prefix code, which means that no code can be a prefix of any other code. In your example, A is a prefix of B, and C is a prefix of both D and E.

A valid prefix code would be:

A: 0
B: 10
C: 11

That's as far as you can go with codes of length 1, 2, and 2. Any other codes would be a prefix of those. It is not possible to have a prefix code with lengths 1, 2, 2, 3, and 3.

This is a valid prefix code for five symbols:

A: 0
B: 10
C: 110
D: 1110
E: 1111

as is this:

A: 00
B: 01
C: 10
D: 110
E: 111
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!