AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Students should be familiar with the process of using a tree to represent…
Full specification wording
Data compression: Students should be familiar with the process of using a tree to represent the Huffman code.
A Huffman tree is a binary tree built from character frequencies so that frequent characters get short codes and rare ones get long codes.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 5 of 13
Study notes
From the checked teaching notes for this specification point.
The idea
A Huffman tree is a binary tree built from character frequencies so that frequent characters get short codes and rare ones get long codes. To build it, list each character with its frequency, then repeatedly take the two lowest-frequency items, join them under a new parent node whose frequency is their sum, and return that parent to the list. Repeat until one root remains. Label each left branch 0 and each right branch 1 (or the reverse, applied consistently). A character's code is the sequence of branch labels on the path from root to that character's leaf. Because every character sits at a leaf, no code is a prefix of another, so decoding is unambiguous.
What earns the marks
- Identifies that the two lowest-frequency nodes (or items) are combined first, and that the new parent's frequency is the sum of the two.
- Recognises that this merging repeats, with the new parent re-entering the list, until a single root node remains.
- States that branch labels (commonly 0 and 1) along the path from root to leaf give each character's code.
- Recognises that characters are stored at leaves, giving prefix-free codes and unambiguous decoding.
- Correctly reads a code or merged frequency from a supplied tree rather than guessing from character order.
Common mistakes and how to put them right
Merging the two highest-frequency items first.
Put it right: Is that Huffman always combines the two lowest-frequency items.
Placing characters at internal nodes.
Put it right: Is that characters belong at leaf nodes, with internal nodes carrying summed frequencies.
Reading a code from leaf to root or mixing branch labels.
Put it right: Is to read consistently from root to leaf using one agreed 0/1 convention.
Exam tips
- Before answering, redraw or annotate the tree and mark each node's frequency so the merge order is visible.
- Check a candidate code by tracing the full root-to-leaf path and confirming no other character's code is a prefix of it.
- For 'next merge' questions, list current node frequencies in order and pick the two smallest, including any newly created parent.
Try the lesson
The start of the Data compression: Students should be familiar with the process of using a tree to represent the Huffman code. lesson, made from checked teaching notes for this specification point.
Have a go first
In a Huffman tree, what does each leaf node represent?
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 the process of using a tree to represent the Huffman code.
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