Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Condition for single bit code for a character in Huffman code?

This is a question I ran into in school settings, but it keeps bugging me so I decided to ask it here.

In Huffman compression, fixed-length sequences (characters) are encoded with variable-length sequences. The code sequence length depends on the frequencies (or probabilities) of the source characters.

My questions is: what is the minimum highest character frequency, with which that character will be encoded by a single bit?

like image 920
daphshez Avatar asked Jun 21 '10 08:06

daphshez


People also ask

How many bits will be required to encode the characters with Huffman coding?

Huffman is an example of a variable-length encoding—some characters may only require 2 or 3 bits and other characters may require 7, 10, or 12 bits.

Is Huffman code a character set?

Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based on the frequencies of corresponding characters. The most frequent character gets the smallest code and the least frequent character gets the largest code.

What is the average bits character of the Huffman code?

By tracing each path through the graph, we can see that the Huffman codewords for this alphabet are: This gives an average codeword length of 2.2 bits/symbol.


1 Answers

It turns out that the answer is 0.4, that is, if the highest frequency p is p >= 0.4, 1-bit code for the corresponding character is guaranteed. In other words, this is a sufficient condition.

It is also true that p >= 1/3 is a necessary condition. That is, there may be examples where 0.4 > p >= 1/3, and the shortest code is 1-bit, but there are no cases like that if p < 1/3.

The way to reason about that is to look at the way the code tree is constructed, in particular at the frequencies of the 3 last surviving subtrees. A proof appears in Johnsen, "On the redundancy of binary Huffman codes", 1980 (unfortunately this is a paid link).

like image 104
daphshez Avatar answered Sep 21 '22 16:09

daphshez