<OJ_Sicily>Huffman coding哈夫曼编码

该篇博客探讨了计算机科学和信息理论中的Huffman编码,这是一种最优前缀编码算法。内容涉及如何利用Huffman编码对给定数据进行编码,并介绍了计算编码数据所需位数的公式。博主给出了输入包含字符及其频率的格式,并要求输出编码的总位数B(T),即各字符频率乘以其在哈夫曼树中的深度之和。文章中提到了利用优先队列来构建和更新哈夫曼树的方法,同时欢迎对代码提供反馈和建议。

Description

In computer science and information theory, a Huffman code is an optimal prefix code algorithm.

In this exercise, please use Huffman coding to encode a given data.

You should output the number of bits, denoted as B(T), to encode the data:

B(T)=∑f(c)dT(c),

where f(c) is the frequency of character c, and dT(c) is be the depth of character c's leaf in the tree T.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值