霍夫曼压缩算法 [英] Huffman compression algorithm

查看:151
本文介绍了霍夫曼压缩算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用huffman的算法实现文件压缩,但我的问题是,启用解压缩压缩文件,使用的编码树,或者代码本身也应该写入文件。问题是:我该怎么做?在压缩文件的开始处编写编码树的最好方法是什么?

I've implemented file compression using huffman's algorithm, but the problem I have is that to enable decompression of the compressed file, the coding tree used, or the codes itself should be written to the file too. The question is: how do i do that? What is the best way to write the coding tree at the beggining of the compressed file?

推荐答案

有一个非常标准的实现Huffman在基本压缩库(BCL)中编码,包括将树写入文件的递归函数。看看huffman.C。它只是写出叶子,以便解码器可以重建相同的树。

There's a pretty standard implementation of Huffman Coding in the Basic Compression Library (BCL), including a recursive function that writes the tree out to a file. Look at huffman.C. It just writes out the leaves in order so the decoder can reconstruct the same tree.

BCL也很不错,因为还有一些其他很简单的压缩算法, 。如果你需要滚动自己的算法,这是非常方便。

BCL is also nice because there are some other pretty straightforward compression algorithm pieces in there, too. It's quite handy if you need to roll your own algorithm.

这篇关于霍夫曼压缩算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆