AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Students should be familiar with carrying out calculations to determine…
Full specification wording
Data compression: Students should be familiar with carrying out calculations to determine the number of bits saved by compressing a piece of data using Huffman coding.
To find the bits saved, compare the uncompressed size with the Huffman-compressed size.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 8 of 13
Study notes
From the checked teaching notes for this specification point.
The idea
To find the bits saved, compare the uncompressed size with the Huffman-compressed size. First work out the uncompressed total: if there are n characters and each uses a fixed length of b bits, the uncompressed size is n × b. Next find the compressed total by multiplying each character's frequency by its Huffman code length and summing the products. The bits saved is uncompressed size minus compressed size. For example, 10 characters at 8 bits each give 80 bits; if the Huffman total is 34 bits, the saving is 80 − 34 = 46 bits. Keep the subtraction the right way round so the answer is positive, and state units in bits.
What earns the marks
- Calculate the uncompressed size as the number of characters multiplied by the fixed bits per character.
- Calculate the compressed size by summing frequency × Huffman code length for every character.
- Subtract the compressed size from the uncompressed size to give the bits saved.
- Keep the subtraction in the correct order so the result is a positive number of bits.
Common mistakes and how to put them right
Subtracting the uncompressed size from the compressed size, giving a negative value.
Put it right: Uncompressed minus compressed.
Forgetting to compute the uncompressed total and comparing against the wrong baseline.
Put it right: Establish n × b first.
Mixing up total bits with bits saved.
Put it right: Finish with the subtraction step the question asks for.
Exam tips
- Show the uncompressed total and the compressed total as separate lines before subtracting.
- Use a table of frequency and code length to avoid arithmetic slips in the compressed total.
- Check the sign and magnitude of the answer; a saving must be positive and smaller than the uncompressed size.
Try the lesson
The start of the Data compression: Students should be familiar with carrying out calculations to determine the number of bits saved by compressing a piece of data using Huffman coding. lesson, made from checked teaching notes for this specification point.
Have a go first
A file contains 200 characters. Each character is stored using 8 bits. After Huffman coding, the same 200 characters need a total of 1100 bits. How many bits are saved by the compression?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Data compression: Students should be familiar with carrying out calculations to determine the number of bits saved by compressing a piece of data using Huffman coding.
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge