- 2076 Asoj (CS II) · 2+2+2 marks
Coding efficiency: binary, Shannon-Fano and Huffman
Short answer
Entropy H = 2.0087 bits/symbol. Fixed-length (3 bits) efficiency is 66.96%. Shannon-Fano and Huffman both yield average length 2.05 bits/symbol, giving 97.99% efficiency.
Compute coding efficiency of a source with symbols {A₀, A₁, A₂, A₃, A₄} with corresponding probabilities {0.4, 0.3, 0.15, 0.1, 0.05} using (i) Binary coding (ii) Shannon-Fano Coding (iii) Binary Huffman Coding
Entropy of the source:
| Symbol | |||
|---|---|---|---|
| A0 | 0.4 | 1.3219 | 0.5288 |
| A1 | 0.3 | 1.7370 | 0.5211 |
| A2 | 0.15 | 2.7370 | 0.4105 |
| A3 | 0.1 | 3.3219 | 0.3322 |
| A4 | 0.05 | 4.3219 | 0.2161 |
| Total | 1 | 2.0087 |
Efficiency is in each case.
(i) Binary (fixed-length) coding
Five symbols need bits each (000, 001, 010, 011, 100), so .
(ii) Shannon–Fano coding
First split: {0.4} vs {0.3, 0.15, 0.1, 0.05} (0.4 vs 0.6; the other split 0.7 vs 0.3 is worse).
| Symbol | Step 1 | Step 2 | Step 3 | Step 4 | Code | ||
|---|---|---|---|---|---|---|---|
| A0 | 0.4 | 0 | 0 | 1 | |||
| A1 | 0.3 | 1 | 0 | 10 | 2 | ||
| A2 | 0.15 | 1 | 1 | 0 | 110 | 3 | |
| A3 | 0.1 | 1 | 1 | 1 | 0 | 1110 | 4 |
| A4 | 0.05 | 1 | 1 | 1 | 1 | 1111 | 4 |
(iii) Binary Huffman coding
Reduction (sum of two lowest moved up as high as possible):
| Stage | Probabilities (descending) | Combined |
|---|---|---|
| 1 | 0.4, 0.3, 0.15, 0.1, 0.05 | 0.1 + 0.05 = 0.15 |
| 2 | 0.4, 0.3, 0.15, 0.15 | 0.15 + 0.15 = 0.3 |
| 3 | 0.4, 0.3, 0.3 | 0.3 + 0.3 = 0.6 |
| 4 | 0.6, 0.4 | 0.6 + 0.4 = 1 |
| Symbol | Huffman code | ||
|---|---|---|---|
| A0 | 0.4 | 1 | 1 |
| A1 | 0.3 | 01 | 2 |
| A2 | 0.15 | 001 | 3 |
| A3 | 0.1 | 0000 | 4 |
| A4 | 0.05 | 0001 | 4 |
| Coding | Efficiency | |
|---|---|---|
| Binary (fixed) | 3 | 66.96 % |
| Shannon–Fano | 2.05 | 97.99 % |
| Huffman | 2.05 | 97.99 % |
Answer: 66.96 %, 97.99 % and 97.99 % respectively.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Importance of source coding; fixed vs Shannon-Fano (five symbols) · Communication Systems, chapter 6
- Importance of source coding; Shannon-Fano vs BCD (four symbols) · Communication Systems, chapter 6
- Importance of source coding; Shannon-Fano vs fixed length (seven symbols) · Communication Systems, chapter 6
- Types of noise; Shannon-Fano and Huffman coding efficiency · Communication Systems, chapter 6
- Huffman and Shannon-Fano coding of A0–A4 · Communication Systems, chapter 6
- Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1) · Communication Systems, chapter 6
- Shannon-Fano code for eight symbols · Data Communication, chapter 8
- Shannon-Fano code for six symbols · Data Communication, chapter 8
- Huffman code for symbols A0 to A4 · Data Communication, chapter 8
- Huffman code for symbols A to E (0.4, 0.3, ...) · Data Communication, chapter 8