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

# Huffman code for a sentence (Phool ko)

Data Communication · Chapter 8: Information Theory and Coding

- Asked in: 2076 Chaitra, 10 marks
- Video: [L-4.4: Huffman Coding Question in Greedy Technique | Imp Question for all competitive exams](https://www.youtube.com/watch?v=ocFO1rmh4Zc) — Gate Smashers
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/data_communication/huffman-phool-ko
- Whole chapter: https://www.bctengineer.com/md/semester_5/data_communication/chapter-8

## Question

Encode "Phool ko aankhama phoolai sansara" using Huffman encoder and find the transmission efficiency.

## Short answer

Using Huffman coding, the average length is L = 3.1724 bits/symbol, entropy H = 3.1213 bits/symbol, and transmission efficiency η = H/L = 98.4%.

## 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 **29 letters** and **11 distinct symbols**.

#### Step 1: frequencies
a=8, o=5, h=3, k=2, l=2, n=2, p=2, s=2, i=1, m=1, r=1

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

```text
 1. i(1) + m(1) = 2  -> N1
 2. r(1) + k(2) = 3  -> N2
 3. l(2) + n(2) = 4  -> N3
 4. p(2) + s(2) = 4  -> N4
 5. N1(2) + h(3) = 5  -> N5
 6. N2(3) + N3(4) = 7  -> N6
 7. N4(4) + o(5) = 9  -> N7
 8. N5(5) + N6(7) = 12  -> N8
 9. a(8) + N7(9) = 17  -> N9
10. N8(12) + N9(17) = 29  -> N10
```

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 | 8 | 8/29 | 10 | 2 |
| o | 5 | 5/29 | 111 | 3 |
| h | 3 | 3/29 | 001 | 3 |
| k | 2 | 2/29 | 0101 | 4 |
| l | 2 | 2/29 | 0110 | 4 |
| n | 2 | 2/29 | 0111 | 4 |
| p | 2 | 2/29 | 1100 | 4 |
| s | 2 | 2/29 | 1101 | 4 |
| i | 1 | 1/29 | 0000 | 4 |
| m | 1 | 1/29 | 0001 | 4 |
| r | 1 | 1/29 | 0100 | 4 |

#### Step 4: entropy, average length and efficiency
- Entropy H = −Σ p log₂ p = **3.1213 bits/symbol**
- Average length L = Σ p·l = 92/29 = **3.1724 bits/symbol**
- Efficiency η = H / L = 3.1213 / 3.1724 = **98.39 %**
- Total bits with Huffman = 92; with fixed-length codes (4 bits/symbol) = 116, so saving = 24 bits.

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

**Transmission efficiency: η ≈ 98.4 %**

The fixed-length alternative would need 4 bits per letter, so Huffman coding also reduces the transmitted bits.

## Check yourself

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

1. Which symbol is most frequent and gets the shortest code?
   A. h with count 3
   B. o with count 5
   C. a with count 8 (code 10)
   D. p with count 2
   Answer: C. a occurs 8 times in 29 letters, so it gets the 2-bit code. (Key point: Symbol statistics)

2. What is the total number of coded bits and L?
   A. 116 bits, L = 4
   B. 92 bits, L = 3.1724
   C. 85 bits, L = 2.93
   D. 29 bits, L = 1
   Answer: B. Total = 92 bits for 29 letters, L = 92/29 = 3.1724. (Key point: Average length)

3. What is the transmission efficiency?
   A. H x L = 99%
   B. H / L = 3.1213/3.1724 = 98.4%
   C. L / H = 101.6%
   D. 1 - H
   Answer: B. Efficiency = entropy / average length = 98.39%. (Key point: Efficiency)

4. How many bits are saved versus 4-bit fixed codes?
   A. 12 bits
   B. 92 bits
   C. 24 bits
   D. 116 bits
   Answer: C. Fixed length needs 29 x 4 = 116 bits, so 116 - 92 = 24 bits are saved. (Key point: Saving versus fixed length)

## Related in Data Communication

- [Huffman code for a sentence (Kun Mandir)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-kun-mandir) — Data Communication, chapter 8
- [Huffman coding of a sentence (Khoji Rahechha)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-khoji-rahechha) — 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 p = 0.6, 0.2, 0.1, 0.05, 0.05](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-p06-02-01) — 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 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

## Related in other subjects

- [Huffman coding of "Engineer Ko Betha Arulai Ke Thaha"](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahuffman-engineer-ko-betha) — Communication Systems, chapter 6
- [Importance of source encoder; Huffman algorithm](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asource-encoder-huffman-algorithm) — Communication Systems, chapter 6
- [Huffman code for five-symbol DMS vs fixed length](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahuffman-dms-five-symbols) — Communication Systems, chapter 6
- [Rate 1/3 convolutional encoder: encode 10011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aconv-encoder-third-rate-10011) — Communication Systems, chapter 8
