Comparison of two Huffman codes:

83 Views Asked by At

A set of eight messages with probabilities of $0.2$, $0.15$, $0.15$, $0.1$, $0.1$, $0.1$, $0.1$, and $0.1$ are encoded into a ternary Huffman code.

One set of Huffman codewords are {$2, 01, 02, 10, 11, 12, 000, 001$} with the average length of the codeword(L) = $2$.

Another set of Huffman codewords are {$00, 01, 02, 10, 11, 12, 20, 21$} also with the average length of the codeword(L) = $2$.

I want to know which set of codewords is better. And if its dependent on the application, please provide some examples.

1

There are 1 best solutions below

0
On

There are multiple reasons you should be interested in the fixed length coding.

  • The first and foremost is that it allows you to find the $N$th symbol very easily, while for variable length codes you have to decode till you find the symbol.
  • Another reason is encoding and decoding is much easier with fixed length codes.
  • The length of output is fixed because the variance of length is zero. For the other one you can easily calculate the variance of length by:

$\sigma^2 = E[(x-\mu)^2] = 1 \times 0.2 + 1 \times 0.1 + 1 \times 0.1 = 0.4$