Haffman Coding

See the ariticle on my own blog https://dyingdown.github.io/2019/10/20/Haffman-Code/.

Assume that we have a bunch of points, each point has a number means the occurrence times of the point.

If we want to label these points with a unique code for each, what do we do?

Well, there are many ways, but I’m just going to show the Haffman coding method.

What is Haffman Coding

In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The process of finding or using such a code proceeds by means of Huffman coding, an algorithm developed by David A. Huffman while he was a Sc.D. student at MIT, and published in the 1952 paper “A Method for the Construction of Minimum-Redundancy Codes”.[1] ——From Wikipedia

Illustration

  1. First we pick up two smallest points and make it one point.

  2. Do the same as 1

  3. Same to 1

  1. Same to 1

  1. Same to 1

  2. Same to 1

  3. Finally we start label the nodes. From the root to the bottom, the code add one digit when the layer is also one deeper. The left is 0 and right is 1.

  4. So we got the haffman code of all the nodes.

    100101010111010010111010110
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值