---
title: "How Huffman code reduces file size"
subject: "Multimedia System"
chapter: 5
key: "semester_8/multimedia_system:huffman-reduces-file-size"
source: https://www.bctengineer.com/q/semester_8/multimedia_system/huffman-reduces-file-size
site: BCT Engineering
---

# How Huffman code reduces file size

Multimedia System · Chapter 5: Data Compression

- Asked in: 2075 Bhadra, 6 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 Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/multimedia_system/huffman-reduces-file-size
- Whole chapter: https://www.bctengineer.com/md/semester_8/multimedia_system/chapter-5

## Question

Explain with example how Huffman code reduces the file size.

## Short answer

Huffman coding assigns short codes to frequent symbols and long codes to rare ones, reducing total bits. For 100 characters with frequencies A45, B20, C15, D10, E10, fixed 3-bit coding needs 300 bits, while Huffman needs 210 bits, saving 30%.

## Answer

Huffman coding reduces file size by replacing fixed-length codes (for example 8-bit ASCII or 3-bit codes) with variable-length codes: common symbols get very short codes and rare symbols get longer ones. Since common symbols occur most, the total number of bits falls.

#### Example
A file has 100 characters made of A, B, C, D, E with frequencies A = 45, B = 20, C = 15, D = 10, E = 10.

**Fixed-length coding:** 5 symbols need 3 bits each.
Total = 100 x 3 = **300 bits**.

**Huffman tree:**
1. D (10) + E (10) = DE (20)
2. C (15) + B (20) = CB (35)
3. DE (20) + CB (35) = DECB (55)
4. A (45) + DECB (55) = root (100)

Codes: A = 0, D = 100, E = 101, C = 110, B = 111.

| Symbol | Frequency | Code | Length | Bits used |
|---|---|---|---|---|
| A | 45 | 0 | 1 | 45 |
| B | 20 | 111 | 3 | 60 |
| C | 15 | 110 | 3 | 45 |
| D | 10 | 100 | 3 | 30 |
| E | 10 | 101 | 3 | 30 |
| Total | 100 | | | **210** |

Average length = 210/100 = 2.1 bits per symbol.

**Saving** = (300 - 210)/300 = 90/300 = **30%**.

Against 8-bit ASCII (800 bits), the Huffman file is 210 bits, a reduction of about 73.8%.

The decoder needs the code table (or frequencies), which is stored as a small header. Because the codes are prefix-free, the bit stream is decoded without separators. The more skewed the symbol frequencies, the greater the saving.

## Check yourself

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

1. How does Huffman coding reduce file size?
   A. It deletes rare symbols
   B. It replaces fixed-length codes with variable-length codes, giving short codes to common symbols
   C. It gives long codes to common symbols
   D. It lowers the image resolution
   Answer: B. Since common symbols occur most often, total bits fall. (Key point: Why file size falls)

2. For frequencies A=45 (code length 1), B=20, C=15, D=10, E=10 (each length 3), how many bits does the Huffman file use?
   A. 300
   B. 250
   C. 210
   D. 180
   Answer: C. 45x1 + (20+15+10+10)x3 = 45 + 165 = 210 bits. (Key point: Bits used)

3. Compared with fixed 3-bit coding of 100 characters (300 bits), what is the saving?
   A. 10%
   B. 30%
   C. 50%
   D. 70%
   Answer: B. (300 - 210)/300 = 30%. (Key point: Saving)

4. When is the saving from Huffman coding greater?
   A. When all symbols have equal frequency
   B. When there are more distinct symbols of equal frequency
   C. When the symbol frequencies are more skewed
   D. When the file has no repeated symbols
   Answer: C. The more uneven the frequencies, the more short codes are used and the greater the saving. (Key point: Condition for greater saving)

## Related in Multimedia System

- [Huffman code tree steps with example](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Ahuffman-code-tree-steps) — Multimedia System, chapter 5, asked 7×
- [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
- [File size: 60 s, 44.1 KHz, 8-bit stereo](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aaudio-size-60s-44khz-8bit) — Multimedia System, chapter 2, asked 3×
- [File size: 30 s, 44.1 KHz, 8-bit stereo](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aaudio-size-30s-44khz-8bit) — Multimedia System, chapter 2, asked 3×
- [File size: 20 s, 44.1 KHz, 16-bit stereo](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aaudio-size-20s-44khz-16bit) — Multimedia System, chapter 2, asked 3×
- [File size: 20 s, 44.1 KHz, 8-bit stereo](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aaudio-size-20s-44khz-8bit) — Multimedia System, chapter 2, asked 2×

## Related in other subjects

- [Algorithm for Huffman code](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Ahuffman-code-algorithm) — Data Structure and Algorithm, chapter 6
- [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 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
