- 2074 Chaitra · 4+4 marks
Huffman code for p = 0.5, 0.25, 0.125, 0.125
Short answer
Huffman coding gives average length 1.7500 bits/symbol and 100% efficiency because probabilities are powers of two.
Write down the Huffman Algorithm clearly. Find an efficient code word and calculate efficiency that can be assigned to the symbols using Huffman Algorithm using probabilities p(x1) = 0.5, p(x2) = 0.25, p(x3) = 0.125, p(x4) = 0.125.
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. x3(0.125) + x4(0.125) = 0.25
2. x2(0.25) + N1(0.25) = 0.5
3. x1(0.5) + N2(0.5) = 1
Code table
| Symbol | p | Code | Length l | p·l |
|---|---|---|---|---|
| x1 | 1/2 | 0 | 1 | 0.5000 |
| x2 | 1/4 | 10 | 2 | 0.5000 |
| x3 | 1/8 | 110 | 3 | 0.3750 |
| x4 | 1/8 | 111 | 3 | 0.3750 |
Entropy, average length, efficiency
- H = −Σ p log₂ p = 1.7500 bits/symbol
- L = Σ p·l = 1.7500 bits/symbol
- Efficiency η = H/L = 1.7500/1.7500 = 100.00 % (redundancy = 0.00 %)
Huffman codes are not unique when probabilities tie, but L and η are the same for every valid choice.
Answer: L = 1.7500 bits/symbol, η = 100.00 %
The probabilities are negative powers of two, so every code length equals −log₂ p, and the code is 100 % efficient (L = H).
✓ 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 eight symbols (1/2 ... 1/128) · 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 a sentence (Kun Mandir) · Data Communication, chapter 8
- Huffman code for symbols A to E (0.4, 0.3, ...) · Data Communication, chapter 8
- Huffman code for symbols A0 to A4 · Data Communication, chapter 8
- Find x3[n] from X3=X1X2, x1 5-point, x2 4-point · Digital Signal Analysis and Processing, chapter 7 · asked 3×
- Huffman code for symbols A to E · Multimedia System, chapter 5
- Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1) · Communication Systems, chapter 6
- Importance of source coding; Huffman for eight symbols at 1000 symbols/s · Communication Systems, chapter 6