---
title: "Huffman code for symbols A to E (0.4, 0.3, ...)"
subject: "Data Communication"
chapter: 8
key: "semester_5/data_communication:huffman-table-abcde"
source: https://www.bctengineer.com/q/semester_5/data_communication/huffman-table-abcde
site: BCT Engineering
---

# Huffman code for symbols A to E (0.4, 0.3, ...)

Data Communication · Chapter 8: Information Theory and Coding

- Asked in: 2069 Chaitra, 1+8 marks
- Video: [L-4.3: Huffman Coding Algorithm in Hindi with Example | Greedy Techniques(Algorithm)](https://www.youtube.com/watch?v=uDS8AkTAcIU) — Gate Smashers
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/data_communication/huffman-table-abcde
- Whole chapter: https://www.bctengineer.com/md/semester_5/data_communication/chapter-8

## Question

What do you mean by entropy? The five symbols from a source and their probabilities are shown in the table below. By using the Huffman algorithm, find the source code for these symbols and determine the average code-word length and the entropy of the source.
| Symbol | Probability |
|---|---|
| A | 0.4 |
| B | 0.3 |
| C | 0.15 |
| D | 0.1 |
| E | 0.05 |

## Short answer

Entropy H = -∑ p log2 p is the average information per symbol, measuring source uncertainty. Huffman coding yields A=0, B=10, C=110, D=1111, E=1110. Average code length L = 2.0500 bits/symbol, entropy H = 2.0087 bits/symbol.

## Answer

**Entropy** is the average information per source symbol, H = −Σ pᵢ log₂ pᵢ bits/symbol. It measures the uncertainty of the source and the minimum average bits per symbol needed to code it.

#### Huffman algorithm
1. Arrange the symbols in decreasing order of probability.
2. Combine the two least probable symbols into one with the sum of their probabilities.
3. Repeat (re-sorting) until only one symbol of probability 1 remains.
4. Assign 0 and 1 to the two branches at every merge.
5. The code of a symbol is the sequence of bits read from the root back to that symbol.

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

```text
1. E(0.05) + D(0.1) = 0.15
2. C(0.15) + N1(0.15) = 0.3
3. B(0.3) + N2(0.3) = 0.6
4. A(0.4) + N3(0.6) = 1
```

#### Code table

| Symbol | p | Code | Length l | p·l |
|---|---|---|---|---|
| A | 0.4 | 0 | 1 | 0.4000 |
| B | 0.3 | 10 | 2 | 0.6000 |
| C | 0.15 | 110 | 3 | 0.4500 |
| D | 0.1 | 1111 | 4 | 0.4000 |
| E | 0.05 | 1110 | 4 | 0.2000 |

#### Entropy, average length, efficiency
- H = −Σ p log₂ p = **2.0087 bits/symbol**
- L = Σ p·l = **2.0500 bits/symbol**
- Efficiency η = H/L = 2.0087/2.0500 = **97.99 %**   (redundancy = 2.01 %)

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

**Answer: L = 2.0500 bits/symbol, η = 97.99 %**

## Check yourself

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

1. What does entropy of the source represent?
   A. Average information per symbol and the minimum average bits per symbol for coding
   B. Maximum codeword length
   C. Number of symbols
   D. Total probability
   Answer: A. H = -Σ p log2 p is the source's uncertainty and the lower bound on average code length. (Key point: Entropy meaning)

2. Which two symbols are merged first?
   A. A and B
   B. D and E
   C. C and D
   D. B and C
   Answer: B. E (0.05) and D (0.1) have the smallest probabilities, giving a node of 0.15. (Key point: First Huffman merge)

3. With code lengths A=1, B=2, C=3, D=4, E=4, what is L?
   A. 2.00
   B. 2.05
   C. 2.50
   D. 1.55
   Answer: B. L = 0.4 + 0.6 + 0.45 + 0.4 + 0.2 = 2.05 bits/symbol. (Key point: Average length)

4. With H = 2.0087 and L = 2.05, what is the efficiency?
   A. About 98 %
   B. About 100 %
   C. About 90 %
   D. About 105 %
   Answer: A. eta = H/L = 2.0087/2.05 = 97.99 %, never above 100 %. (Key point: Efficiency)

## Related in Data Communication

- [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.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 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 six symbols (0.04, 0.1, ...)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahuffman-six-symbols-004) — 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
- [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 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
- [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
- [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 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
