简体   繁体   English

如何在霍夫曼编码中解压缩字符串?

[英]How to decompress a string in huffman coding?

I compressed the "abc" word into "01100111" using haffman coding algorithm .我使用哈夫曼编码算法将“abc”字压缩成“01100111”。 I built the tree .我建造了这棵树。 According to tree a=01, b=100 , c=111 .根据树 a=01, b=100 , c=111 。 how to decompress this word ?这个词怎么解压?

That is not a Huffman code.那不是霍夫曼代码。 A Huffman code is a prefix code that uses all possible bit patterns.霍夫曼码是使用所有可能位模式的前缀码。 The prefixes 00, 101, and 110 are not used.不使用前缀 00、101 和 110。

To decode a prefix code, you effectively traverse the tree starting at the root until you get to a leaf.要解码前缀代码,您可以有效地从根开始遍历树,直到到达叶子为止。 Then you emit the symbol at the leaf and start over again at the root.然后在叶子处发出符号并在根处重新开始。

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

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