---
title: "Importance of source coding; Shannon-Fano vs BCD (four symbols)"
subject: "Communication Systems"
chapter: 6
key: "semester_6/communication_systems:source-coding-sf-bcd-four"
source: https://www.bctengineer.com/q/semester_6/communication_systems/source-coding-sf-bcd-four
site: BCT Engineering
---

# Importance of source coding; Shannon-Fano vs BCD (four symbols)

Communication Systems · Chapter 6: Baseband Digital Data Transmission

- Asked in: 2071 Chaitra (CS II), 2+4+2 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/communication_systems/source-coding-sf-bcd-four
- Whole chapter: https://www.bctengineer.com/md/semester_6/communication_systems/chapter-6

## Question

Explain the importance of source coding in digital communication system. A discrete memory less source emits four symbols with probabilities P = {0.125, 0.125, 0.25, 0.5}. If the output symbols are encoded using Shannon Fano code, find the Coding efficiency and compare the coding efficiency with that of BCD code.

## Short answer

Source coding reduces bit rate by giving short codes to probable symbols. With probabilities 0.5,0.25,0.125,0.125, Shannon-Fano achieves average length 1.75 bits/symbol, matching entropy, for 100% efficiency. BCD with 4 bits per symbol yields only 43.75% efficiency.

## Answer

#### Importance of source coding

Source coding removes redundancy from the source output so that each symbol is represented by as few bits as possible on average:

- It reduces the bit rate, so less bandwidth, power and storage are needed.
- It uses the symbol probabilities: likely symbols get short code words.
- The best possible average length is the entropy $H$; efficiency $\eta = H/\bar L$ shows how close a code comes.

#### Shannon–Fano code

$P = \{0.125, 0.125, 0.25, 0.5\}$ for $x_1, x_2, x_3, x_4$. In decreasing order: $x_4$ 0.5, $x_3$ 0.25, $x_1$ 0.125, $x_2$ 0.125. Splits: {0.5} | {0.25, 0.125, 0.125}; {0.25} | {0.125, 0.125}; {0.125} | {0.125}.

| Symbol | $p_i$ | Step 1 | Step 2 | Step 3 | Code | $l_i$ |
|---|---|---|---|---|---|---|
| x4 | 0.5 | 0 |  |  | 0 | 1 |
| x3 | 0.25 | 1 | 0 |  | 10 | 2 |
| x1 | 0.125 | 1 | 1 | 0 | 110 | 3 |
| x2 | 0.125 | 1 | 1 | 1 | 111 | 3 |

**Entropy:**

| Symbol | $p_i$ | $\log_2(1/p_i)$ | $p_i\log_2(1/p_i)$ |
|---|---|---|---|
| x1 | 0.125 | 3.0000 | 0.3750 |
| x2 | 0.125 | 3.0000 | 0.3750 |
| x3 | 0.25 | 2.0000 | 0.5000 |
| x4 | 0.5 | 1.0000 | 0.5000 |
| **Total** | 1 | | **1.7500** |

$$
\begin{aligned}
H &= 0.5(1) + 0.25(2) + 2(0.125)(3) = 1.75\ \text{bits/symbol} \\
\bar L_{SF} &= 0.5(1) + 0.25(2) + 0.125(3) + 0.125(3) = 1.75\ \text{bits/symbol} \\
\eta_{SF} &= \frac{1.75}{1.75} = 100\%
\end{aligned}
$$

#### Comparison with BCD

In BCD each symbol is sent as a 4-bit binary-coded-decimal word (0000, 0001, 0010, 0011), so $\bar L = 4$:

$$
\eta_{BCD} = \frac{1.75}{4} = 43.75\%
$$

| Code | $\bar L$ | Efficiency |
|---|---|---|
| Shannon–Fano | 1.75 | 100 % |
| BCD (4 bits) | 4 | 43.75 % |

Shannon–Fano reaches 100 % because all probabilities are powers of $\frac12$. (If "BCD" is read as the plain 2-bit binary code, $\eta = 1.75/2 = 87.5\%$; Shannon–Fano is still better.)

## Check yourself

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

1. For P = {0.5, 0.25, 0.125, 0.125}, what is the entropy?
   A. 1.5 bits
   B. 1.75 bits
   C. 2 bits
   D. 1.25 bits
   Answer: B. H = 0.5(1)+0.25(2)+2(0.125)(3) = 1.75 bits/symbol. (Key point: Entropy of source)

2. Why does Shannon-Fano reach 100% efficiency here?
   A. All probabilities are powers of 1/2
   B. All symbols are equally likely
   C. BCD is used
   D. The source is binary
   Answer: A. Code lengths equal log2(1/p) exactly, so L = H = 1.75. (Key point: Why 100% efficiency)

3. If BCD uses 4 bits per symbol, what is its efficiency here?
   A. 43.75%
   B. 87.5%
   C. 100%
   D. 25%
   Answer: A. 1.75/4 = 43.75%, much lower than Shannon-Fano's 100%. (Key point: BCD comparison)

## Related in Communication Systems

- [Importance of source coding; fixed vs Shannon-Fano (five symbols)](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asource-coding-fixed-sf-five) — Communication Systems, chapter 6
- [Importance of source coding; Shannon-Fano vs fixed length (seven symbols)](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asource-coding-sf-fixed-seven) — Communication Systems, chapter 6
- [Digital communication system; Shannon-Fano for six symbols](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Adcs-block-shannon-fano-six) — Communication Systems, chapter 6
- [Importance of source coding; Huffman for eight symbols at 1000 symbols/s](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asource-coding-huffman-eight-1000) — Communication Systems, chapter 6
- [Digital communication system elements; Shannon-Fano coding](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Adcs-block-shannon-fano) — Communication Systems, chapter 6
- [Coding efficiency: binary, Shannon-Fano and Huffman](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Acoding-efficiency-binary-sf-huffman) — Communication Systems, chapter 6

## Related in other subjects

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