- 2069 Chaitra · 1+8 marks
Huffman code for symbols A to E (0.4, 0.3, ...)
Short answer
Entropy H = -∑ p log2 p is the average information per symbol, measuring source uncertainty. Huffman coding yields A=0, B=10, C=110, D=1111, E=1110. Average code length L = 2.0500 bits/symbol, entropy H = 2.0087 bits/symbol.
What do you mean by entropy? The five symbols from a source and their probabilities are shown in the table below. By using the Huffman algorithm, find the source code for these symbols and determine the average code-word length and the entropy of the source.
| Symbol | Probability |
|---|---|
| A | 0.4 |
| B | 0.3 |
| C | 0.15 |
| D | 0.1 |
| E | 0.05 |
Entropy is the average information per source symbol, H = −Σ pᵢ log₂ pᵢ bits/symbol. It measures the uncertainty of the source and the minimum average bits per symbol needed to code it.
Huffman algorithm
- Arrange the symbols in decreasing order of probability.
- Combine the two least probable symbols into one with the sum of their probabilities.
- Repeat (re-sorting) until only one symbol of probability 1 remains.
- Assign 0 and 1 to the two branches at every merge.
- The code of a symbol is the sequence of bits read from the root back to that symbol.
Merging steps
At every step the two smallest probabilities are combined (N1, N2, ... are the new nodes):
1. E(0.05) + D(0.1) = 0.15
2. C(0.15) + N1(0.15) = 0.3
3. B(0.3) + N2(0.3) = 0.6
4. A(0.4) + N3(0.6) = 1
Code table
| Symbol | p | Code | Length l | p·l |
|---|---|---|---|---|
| A | 0.4 | 0 | 1 | 0.4000 |
| B | 0.3 | 10 | 2 | 0.6000 |
| C | 0.15 | 110 | 3 | 0.4500 |
| D | 0.1 | 1111 | 4 | 0.4000 |
| E | 0.05 | 1110 | 4 | 0.2000 |
Entropy, average length, efficiency
- H = −Σ p log₂ p = 2.0087 bits/symbol
- L = Σ p·l = 2.0500 bits/symbol
- Efficiency η = H/L = 2.0087/2.0500 = 97.99 % (redundancy = 2.01 %)
Huffman codes are not unique when probabilities tie, but L and η are the same for every valid choice.
Answer: L = 2.0500 bits/symbol, η = 97.99 %
✓ Answer checked by Claude Sonnet 5.5
Related questions
- Huffman code for five symbols (0.2, 0.35, ...) · Data Communication, chapter 8
- Huffman code for p = 0.6, 0.2, 0.1, 0.05, 0.05 · Data Communication, chapter 8
- Huffman code for eight symbols (1/2 ... 1/128) · Data Communication, chapter 8
- Huffman code for six symbols (0.04, 0.1, ...) · Data Communication, chapter 8
- Huffman code for symbols A0 to A4 · Data Communication, chapter 8
- Huffman code for p = 0.5, 0.25, 0.125, 0.125 · Data Communication, chapter 8
- Huffman code for five-symbol DMS vs fixed length · Communication Systems, chapter 6
- Source vs channel coding; Huffman for five symbols · Communication Systems, chapter 6
- Huffman code for seven-symbol source · Communication Systems, chapter 6
- Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1) · Communication Systems, chapter 6