摘要
研究数据压缩方法,用哈夫曼算法实现一个文件压缩器。把文件中字节码的频数作为权重,用优先队列构建哈夫曼树,构造字节码和哈夫曼码的转换表,利用转换表对文件字节码实施变换实现压缩,用对象序列化的方法保存转换表和压缩数据。解压过程中用转换表对压缩数据作逆变换得到字节码,实现文件解压。
The method of data compression is studied in this paper, and a file compression software was implemented by using Huffman algorithm. A priority queue was used to build a Huffman tree with character frequency used as weight. A mapping table was constructed in which a byte-code was mapped into a Huffman-code, and then byte-codes in a file were transformed Huffman-eodes to compress a file by using the mapping table. The mapping table and the compressed data were saved in object serialization. The compressed data was transformed inversely from Huffman-codes to byte-codes to achieve decompression of file by using the mapping table in the process of decompression.
出处
《电脑编程技巧与维护》
2013年第2期35-37,共3页
Computer Programming Skills & Maintenance
关键词
数据压缩
哈夫曼算法
优先队列
对象序列化
data compression
Huffman algorithm
priority queue
object serialization