Huffman coding: counting the bits – AQA GCSE Computer Science lesson (8525)
Pupils learn to calculate the bits needed for text in Huffman coding and in 7-bit ASCII and the bits saved.
Lesson 4 of 11 in unit 10.5 Compression, Networks and Searching, taught in Year 10, Summer 1. It answers one big question: How many bits does Huffman coding save?
By the end, pupils can calculate the bits needed for text in Huffman coding and in 7-bit ASCII and the bits saved.
- The Build (the main task)
- Calculate the number of bits needed to store the message using the Huffman codes in the table. Show your working. (3 marks) Calculate the number of bits needed to store the message in 7-bit ASCII, and the number of bits saved by using Huffman coding. Show your working. (2 marks)
- Support version
- A table with the columns character, frequency, code length and bits, partly filled.
- Challenge
- Another test message is BOOK NOOK OK BOOKS (18 characters). The Huffman codes are O 0, K 10, space 110, B 1110, N 11110, S 11111. Calculate the bits needed using these codes and the bits saved against 7-bit ASCII. Show your working. (3 marks) Explain why Huffman coding saves more bits on a long text in which a few characters are very common. (4 marks) A librarian suggests giving every character in a four-character set (O, K, B, N) a 1-bit Huffman code to save even more. Explain why this is not possible, and state the fewest bits the message OOKB could then take. (4 marks)
- Real-world link
- How many bits does Huffman coding save on the library's daily catalogue update?
- Key words
- Huffman coding, ASCII and Compare, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “Huffman bits = number of characters × the longest code”; “Uncompressed ASCII uses 8 bits a character”.
- AQA 8525 specification
- 3.3.8 (data compression: why compress; Huffman coding and trees; bits in Huffman and ASCII; run length encoding).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils can do it all on paper.
Also sold in the Compression, Networks and Searching unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for AQA GCSE Computer Science (8525). It is not endorsed by AQA.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for GCSE Computer Science (AQA)
See allPupils learn to explain what data compression is and why it is used, and represent data as run length encoding frequency/data pairs.
Pupils learn to complete trace tables for algorithms in AQA pseudo-code, flowcharts and the class's language, and state an algorithm's purpose.
Pupils learn to explain how Huffman coding compresses data and read characters' codes from a Huffman tree.
Written for the specifications named. Not endorsed by or affiliated with any exam board.