- 2074 Asoj · 10 marks
Huffman code for five symbols (0.2, 0.35, ...)
Short answer
Huffman coding yields average length 2.2500 bits/symbol and efficiency 97.85%.
Consider a five symbol source with probability assignment as P(X1)=0.2, P(X2)=0.35, P(X3)=0.1, P(X4)=0.2, P(X5)=0.15. By using Huffman algorithm, find the source code for these symbols and determine efficiency of the code.
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.
Probabilities: P(X1) = 0.2, P(X2) = 0.35, P(X3) = 0.1, P(X4) = 0.2, P(X5) = 0.15 (sum = 1).
Merging steps
At every step the two smallest probabilities are combined (N1, N2, ... are the new nodes):
1. X3(0.1) + X5(0.15) = 0.25
2. X1(0.2) + X4(0.2) = 0.4
3. N1(0.25) + X2(0.35) = 0.6
4. N2(0.4) + N3(0.6) = 1
Code table
| Symbol | p | Code | Length l | p·l |
|---|---|---|---|---|
| X2 | 0.35 | 11 | 2 | 0.7000 |
| X1 | 0.2 | 00 | 2 | 0.4000 |
| X4 | 0.2 | 01 | 2 | 0.4000 |
| X5 | 0.15 | 101 | 3 | 0.4500 |
| X3 | 0.1 | 100 | 3 | 0.3000 |
Entropy, average length, efficiency
- H = −Σ p log₂ p = 2.2016 bits/symbol
- L = Σ p·l = 2.2500 bits/symbol
- Efficiency η = H/L = 2.2016/2.2500 = 97.85 % (redundancy = 2.15 %)
Huffman codes are not unique when probabilities tie, but L and η are the same for every valid choice.
Answer: L = 2.2500 bits/symbol, η = 97.85 %
✓ Answer checked by Claude Sonnet 5.5
Related questions
- Huffman code for eight symbols (1/2 ... 1/128) · Data Communication, chapter 8
- Huffman code for symbols A to E (0.4, 0.3, ...) · Data Communication, chapter 8
- Huffman code for six symbols (0.04, 0.1, ...) · 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 p = 0.5, 0.25, 0.125, 0.125 · Data Communication, chapter 8
- Shannon-Fano code for eight symbols · Data Communication, chapter 8
- Source vs channel coding; Huffman for five symbols · Communication Systems, chapter 6
- Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1) · Communication Systems, chapter 6
- Huffman code for five-symbol DMS vs fixed length · Communication Systems, chapter 6
- Huffman code for seven-symbol source · Communication Systems, chapter 6