霍夫曼算法_霍夫曼编码算法

霍夫曼算法

In this tutorial, we’ll be discussing and implementing the Huffman Coding Algorithm in Java.

在本教程中,我们将讨论和实现Java中的霍夫曼编码算法。

霍夫曼编码 (Huffman Coding)

The Huffman Coding Algorithm was discovered by David A. Huffman in the 1950s. The purpose of the Algorithm is lossless data compression.

霍夫曼编码算法由戴维·霍夫曼(David A. Huffman)在1950年代发现。 该算法的目的是无损数据压缩。

This algorithm is commonly used in JPEG Compression.

此算法通常在JPEG压缩中使用。

Now traditionally to encode/decode a string, we can use ASCII values. But this doesn’t compress it. The number of bits involved in encoding the string isn’t reduced.

现在传统上是对字符串进行编码/解码,我们可以使用ASCII值。 但这并没有压缩它。 编码字符串所涉及的位数不会减少。

Unlike ASCII codes, Huffman codes use lesser number of bits.

与ASCII码不同,霍夫曼码使用的位数更少。

The principle of Huffman code is based on the frequency of each data item.

霍夫曼编码的原理是基于每个数据项的频率。

Every data item is assigned a variable length of prefix code (typically a binary string).

每个数据项都分配有可变长度的前缀代码(通常是二进制字符串)。

The length of each prefix code is based on the frequency such that the most commonly occurring data has the smallest prefix code.

每个前缀码的长度基于频率,以使最常出现的数据具有最小的前缀码。

No two different data items would have the same prefix. Hence the prefixes are known as Prefix Codes. This is important to make sure decoded string is the same as the original string.

没有两个不同的数据项具有相同的前缀。 因此,前缀称为前缀代码 。 确保解码后的字符串与原始字符串相同非常重要。

The more often the data is used the lesser bits it takes up.

使用数据的频率越高,占用的比特就越少。

A Disadvantage of Huffman codes

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值