---
title: "Huffman code for a sentence (Kun Mandir)"
subject: "Data Communication"
chapter: 8
key: "semester_5/data_communication:huffman-kun-mandir"
source: https://www.bctengineer.com/q/semester_5/data_communication/huffman-kun-mandir
site: BCT Engineering
---

# Huffman code for a sentence (Kun Mandir)

Data Communication · Chapter 8: Information Theory and Coding

- Asked in: 2078 Kartik, 10 marks
- Video: [Huffman Coding Technique for binary system.](https://www.youtube.com/watch?v=EPtWCVSZqi8) — WIT Solapur - Professional Learning Community
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/data_communication/huffman-kun-mandir
- Whole chapter: https://www.bctengineer.com/md/semester_5/data_communication/chapter-8

## Question

Write down the Huffman algorithm clearly and find an efficient code word and efficiency that can be assigned to the symbols using the Huffman algorithm for "Kun Mandir Ma Janchhau Yattri".

## Short answer

Using letter frequencies from the phrase, Huffman coding yields entropy H = 3.5093 bits/symbol, average length L = 3.5600 bits/symbol. Efficiency η = H/L ≈ 98.6%.

## Answer

**Assumptions:** spaces are ignored, upper and lower case letters are treated as the same symbol, and each letter is a source symbol. The sentence has **25 letters** and **13 distinct symbols**.

#### Huffman algorithm
1. List symbols with their probabilities.
2. Merge the two smallest probabilities into one node (sum).
3. Repeat until one node remains.
4. Label branches 0 and 1; read each code from the root to the leaf.

#### Step 1: frequencies
a=5, n=3, h=2, i=2, m=2, r=2, t=2, u=2, c=1, d=1, j=1, k=1, y=1

#### Step 2: build the Huffman tree
Repeatedly merge the two smallest weights (N1, N2, ... are the new nodes):

```text
 1. c(1) + d(1) = 2  -> N1
 2. j(1) + k(1) = 2  -> N2
 3. y(1) + h(2) = 3  -> N3
 4. i(2) + m(2) = 4  -> N4
 5. r(2) + t(2) = 4  -> N5
 6. u(2) + N1(2) = 4  -> N6
 7. N2(2) + n(3) = 5  -> N7
 8. N3(3) + N4(4) = 7  -> N8
 9. N5(4) + N6(4) = 8  -> N9
10. a(5) + N7(5) = 10  -> N10
11. N8(7) + N9(8) = 15  -> N11
12. N10(10) + N11(15) = 25  -> N12
```

The branch to the smaller-weight node is labelled 0 and to the larger 1, and the codes are read from the root downwards.

#### Step 3: code table

| Symbol | Count | p | Code | Length |
|---|---|---|---|---|
| a | 5 | 5/25 | 00 | 2 |
| n | 3 | 3/25 | 011 | 3 |
| h | 2 | 2/25 | 1001 | 4 |
| i | 2 | 2/25 | 1010 | 4 |
| m | 2 | 2/25 | 1011 | 4 |
| r | 2 | 2/25 | 1100 | 4 |
| t | 2 | 2/25 | 1101 | 4 |
| u | 2 | 2/25 | 1110 | 4 |
| c | 1 | 1/25 | 11110 | 5 |
| d | 1 | 1/25 | 11111 | 5 |
| j | 1 | 1/25 | 0100 | 4 |
| k | 1 | 1/25 | 0101 | 4 |
| y | 1 | 1/25 | 1000 | 4 |

#### Step 4: entropy, average length and efficiency
- Entropy H = −Σ p log₂ p = **3.5093 bits/symbol**
- Average length L = Σ p·l = 89/25 = **3.5600 bits/symbol**
- Efficiency η = H / L = 3.5093 / 3.5600 = **98.58 %**
- Total bits with Huffman = 89; with fixed-length codes (4 bits/symbol) = 100, so saving = 11 bits.

(Huffman codes are not unique when weights tie, but every choice gives the same average length and efficiency.)

**Answer: η ≈ 98.6 %**

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does the answer find for the sentence (ignoring spaces and case)?
   A. 25 letters and 13 distinct symbols
   B. 25 letters and 25 distinct symbols
   C. 30 letters and 13 distinct symbols
   D. 13 letters and 25 distinct symbols
   Answer: A. The sentence has 25 letters with 13 distinct symbols; a has the highest count, 5. (Key point: Symbol statistics)

2. What is done first when building the tree?
   A. Merge a(5) and n(3)
   B. Merge the two smallest weights, such as c(1) and d(1)
   C. Merge the two largest weights
   D. Assign 0 and 1 to leaves arbitrarily
   Answer: B. Huffman always merges the two smallest weights first. (Key point: First merge)

3. What are the total bits and average length?
   A. 100 bits, 4.00 bits/symbol
   B. 89 bits, 3.56 bits/symbol
   C. 75 bits, 3.00 bits/symbol
   D. 89 bits, 3.5093 bits/symbol
   Answer: B. Total = 89 bits over 25 letters, so L = 3.56 bits/symbol. (Key point: Average length)

4. With H = 3.5093 and L = 3.56, what is the efficiency?
   A. 101.4%
   B. 98.6%
   C. 89%
   D. 70%
   Answer: B. eta = H/L = 3.5093/3.5600 = 98.58%, about 98.6%. (Key point: Efficiency)

## Related in Data Communication

- [Huffman code for p = 0.5, 0.25, 0.125, 0.125](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-p05-025-0125) — Data Communication, chapter 8
- [Huffman code for symbols A to E (0.4, 0.3, ...)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-table-abcde) — Data Communication, chapter 8
- [Huffman code for five symbols (0.2, 0.35, ...)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-five-symbols-02-035) — Data Communication, chapter 8
- [Huffman code for eight symbols (1/2 ... 1/128)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-eight-symbols) — Data Communication, chapter 8
- [Huffman code for a sentence (Phool ko)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-phool-ko) — Data Communication, chapter 8
- [Huffman code for symbols A0 to A4](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-a0-a4) — Data Communication, chapter 8

## Related in other subjects

- [Source coding aim; Huffman "Kun Mandir Ma Janchhau Yatri"](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahuffman-kun-mandir) — Communication Systems, chapter 6
- [Huffman code for symbols A to E](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Ahuffman-numerical-abcde) — Multimedia System, chapter 5
