在霍夫曼压缩后将代码表存储在压缩文件中,并从该表中构建用于解压缩的树 [英] Storing table of codes in a compressed file after Huffman compression and building tree for decompression from this table

查看:56
本文介绍了在霍夫曼压缩后将代码表存储在压缩文件中,并从该表中构建用于解压缩的树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C ++编写霍夫曼压缩程序,但遇到压缩文件结构的问题.它需要在我的新文件中存储一些结构,可以帮助我对该文件进行解码.我决定在此文件的开头编写一个代码表,然后从该表构建一棵树以解码下一个内容,但是我不知道以哪种方式存储该表会更好(我的意思是我不知道表的结构,我知道如何用二进制模式编写东西)以及如何从此表构建树.对不起我的英语不好.先感谢您.

I was writing a program of Huffman compression using C++ but I faced with a problem of compressed file's structure. It needs to store some structure in my new file that can help me to decode this file. I decided to write a table of codes in the beginning of this file and then build a tree from this table to decode the next content, but I do not know in which way it is better to store the table (I mean I do not know structure of the table, I know how to write things in binary mode) and how to build the tree from this table. Sorry for my English. Thank you in advance.

推荐答案

您可以根据字符出现在文本中的可能性,尝试使用字符序列在压缩文件中写入标头.或在字母后面加上概率.这样,您就可以使用相同的过程来构建用于压缩和解压缩的树.至于如何构建树本身,我想您需要做一些研究,如果有问题请回来.

You could try writing a header in the compressed file with the sequence of characters according to their probability of appearing in the text. Or writing the letters followed by their probabilities. With that, you use the same process for building the tree for compressing and decompressing. As for how to build the tree itself, I suppose you'll have to do a little research and come back you if have problems.

这篇关于在霍夫曼压缩后将代码表存储在压缩文件中,并从该表中构建用于解压缩的树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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