---
title: "Huffman code for six symbols (0.04, 0.1, ...)"
subject: "Data Communication"
chapter: 8
key: "semester_5/data_communication:huffman-six-symbols-004"
source: https://www.bctengineer.com/q/semester_5/data_communication/huffman-six-symbols-004
site: BCT Engineering
---

# Huffman code for six symbols (0.04, 0.1, ...)

Data Communication · Chapter 8: Information Theory and Coding

- Asked in: 2073 Shrawan, 6 marks
- Video: [Calculate Efficiency of Huffman Code for the symbol whose probability of occurrence by Mahesh Huddar](https://www.youtube.com/watch?v=NNAGT1I94Gg) — Mahesh Huddar
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/data_communication/huffman-six-symbols-004
- Whole chapter: https://www.bctengineer.com/md/semester_5/data_communication/chapter-8

## Question

Design a Binary Huffman code with a six symbol source with probability assignment as: P(s1)=0.04, P(s2)=0.1, P(s3)=0.1, P(s4)=0.4, P(s5)=0.06 and P(s6)=0.3.

## Short answer

Huffman coding yields average length 2.2000 bits/symbol and efficiency 97.43%.

## Answer

Probabilities: s4 = 0.4, s6 = 0.3, s2 = 0.1, s3 = 0.1, s5 = 0.06, s1 = 0.04 (sum = 1).

#### Merging steps
At every step the two smallest probabilities are combined (N1, N2, ... are the new nodes):

```text
1. s1(0.04) + s5(0.06) = 0.1
2. s2(0.1) + s3(0.1) = 0.2
3. N1(0.1) + N2(0.2) = 0.3
4. s6(0.3) + N3(0.3) = 0.6
5. s4(0.4) + N4(0.6) = 1
```

#### Code table

| Symbol | p | Code | Length l | p·l |
|---|---|---|---|---|
| s4 | 0.4 | 0 | 1 | 0.4000 |
| s6 | 0.3 | 10 | 2 | 0.6000 |
| s2 | 0.1 | 1110 | 4 | 0.4000 |
| s3 | 0.1 | 1111 | 4 | 0.4000 |
| s5 | 0.06 | 1101 | 4 | 0.2400 |
| s1 | 0.04 | 1100 | 4 | 0.1600 |

#### Entropy, average length, efficiency
- H = −Σ p log₂ p = **2.1435 bits/symbol**
- L = Σ p·l = **2.2000 bits/symbol**
- Efficiency η = H/L = 2.1435/2.2000 = **97.43 %**   (redundancy = 2.57 %)

Huffman codes are not unique when probabilities tie, but L and η are the same for every valid choice.

**Answer: L = 2.2000 bits/symbol, η = 97.43 %**

## Check yourself

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

1. What is merged first for the six-symbol source?
   A. s4 and s6
   B. s1 (0.04) and s5 (0.06) to give 0.1
   C. s2 and s3
   D. s6 and s2
   Answer: B. The two smallest probabilities, 0.04 and 0.06, are merged. (Key point: First merge)

2. Which symbols receive 1-bit and 2-bit codes?
   A. s1 and s5
   B. s4 (0) and s6 (10)
   C. s2 and s3
   D. s6 (0) and s4 (10)
   Answer: B. The two most probable symbols s4 (0.4) and s6 (0.3) get the shortest codes. (Key point: Code lengths)

3. What are L and efficiency?
   A. L = 2.2 bits, eta = 97.43%
   B. L = 2.1435, eta = 100%
   C. L = 3, eta = 71%
   D. L = 2.5, eta = 85%
   Answer: A. L = 0.4+0.6+0.4+0.4+0.24+0.16 = 2.2; eta = 2.1435/2.2 = 97.43%. (Key point: Average length)

## Related in Data Communication

- [Shannon-Fano code for six symbols](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ashannon-fano-six-symbols) — 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 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 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 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

- [Huffman code for seven-symbol source](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahuffman-seven-symbols) — Communication Systems, chapter 6
- [Source vs channel coding; Huffman for five symbols](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asource-channel-huffman-five) — Communication Systems, chapter 6
- [Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1)](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asource-coding-huffman-five-s0) — 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
