- 2079 Chaitra · 10 marks
Source coding aim; Huffman "Kun Mandir Ma Janchhau Yatri"
Short answer
Source coding aims to compress data by removing redundancy, using short codes for frequent symbols to reduce average bit rate while allowing exact recovery. Huffman coding of the phrase yields average length 3.607 bits/symbol, entropy 3.580 bits/symbol, and efficiency 99.25%.
What is the aim of source coding? Encode "Kun Mandir Ma Janchhau Yatri" using Huffman codes and find its efficiency.
Aim of source coding
Source coding represents the output of an information source with as few bits as possible, while still allowing the receiver to recover it exactly (lossless coding) or acceptably (lossy coding). Its aims are:
- Remove redundancy: give short code words to frequent symbols and long ones to rare symbols, so the average code length approaches the entropy (Shannon's source coding theorem: ).
- Raise efficiency towards 100%.
- Lower the bit rate, which saves bandwidth, storage and transmission power.
- Produce a uniquely decodable (prefix) code so the receiver can decode it without separators.
Examples are Huffman, Shannon–Fano and LZW coding, as well as speech and image compression.
Huffman coding of "Kun Mandir Ma Janchhau Yatri"
Assumptions: case is ignored, and the space is counted as a symbol. The message has 28 symbols and 14 distinct symbols.
Huffman procedure: list the symbols by probability. Repeatedly combine the two least probable entries into one node whose weight is their sum, until only one node is left. In each merge, the first group listed gets bit 0 and the second group gets bit 1. Each symbol's code word is read from the root down to that symbol.
Merge steps:
- {d} (1) + {c} (1) → 2
- {k} (1) + {j} (1) → 2
- {y} (1) + {t} (1) → 2
- {i} (2) + {h} (2) → 4
- {r} (2) + {m} (2) → 4
- {d, c} (2) + {u} (2) → 4
- {y, t} (2) + {k, j} (2) → 4
- {space} (4) + {n} (3) → 7
- {r, m} (4) + {i, h} (4) → 8
- {y, t, k, j} (4) + {d, c, u} (4) → 8
- {space, n} (7) + {a} (5) → 12
- {y, t, k, j, d, c, u} (8) + {r, m, i, h} (8) → 16
- {y, t, k, j, d, c, u, r, m, i, h} (16) + {space, n, a} (12) → 28
| Symbol | Count | Code | |||
|---|---|---|---|---|---|
| a | 5 | 5/28 = 0.1786 | 11 | 2 | 0.3571 |
| space | 4 | 4/28 = 0.1429 | 100 | 3 | 0.4286 |
| n | 3 | 3/28 = 0.1071 | 101 | 3 | 0.3214 |
| h | 2 | 2/28 = 0.0714 | 0111 | 4 | 0.2857 |
| i | 2 | 2/28 = 0.0714 | 0110 | 4 | 0.2857 |
| m | 2 | 2/28 = 0.0714 | 0101 | 4 | 0.2857 |
| r | 2 | 2/28 = 0.0714 | 0100 | 4 | 0.2857 |
| u | 2 | 2/28 = 0.0714 | 0011 | 4 | 0.2857 |
| c | 1 | 1/28 = 0.0357 | 00101 | 5 | 0.1786 |
| d | 1 | 1/28 = 0.0357 | 00100 | 5 | 0.1786 |
| j | 1 | 1/28 = 0.0357 | 00011 | 5 | 0.1786 |
| k | 1 | 1/28 = 0.0357 | 00010 | 5 | 0.1786 |
| t | 1 | 1/28 = 0.0357 | 00001 | 5 | 0.1786 |
| y | 1 | 1/28 = 0.0357 | 00000 | 5 | 0.1786 |
Average code length:
Here the numerator is the total number of bits in the encoded message: bits.
Entropy:
Efficiency:
Redundancy .
A fixed-length code for 14 symbols needs bits/symbol (). Huffman saves 9.82% of the bits.
Answer: bits/symbol, bits/symbol, efficiency η ≈ 99.25%. The message needs 101 bits instead of 112 bits with a 4-bit fixed code.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Source vs channel coding; Huffman for five symbols · Communication Systems, chapter 6
- Importance of source coding; Huffman for eight symbols at 1000 symbols/s · Communication Systems, chapter 6
- Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1) · Communication Systems, chapter 6
- Types of noise; Shannon-Fano and Huffman coding efficiency · Communication Systems, chapter 6
- Coding efficiency: binary, Shannon-Fano and Huffman · Communication Systems, chapter 6
- Information rate and coding efficiency: BCD vs Huffman · Communication Systems, chapter 6
- Huffman code for a sentence (Kun Mandir) · Data Communication, chapter 8
- Source coding; fixed vs variable length codes · Data Communication, chapter 8
- Line coding: properties; encode 01001100011 · Data Communication, chapter 5
- Huffman coding of a sentence (Khoji Rahechha) · Data Communication, chapter 8