Data Compression: RLE and Huffman Coding
Aligned to the AQA 8525 specification
- Level
- Advanced
- Reading time
- 7 min
- Published
- 3 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- Data compression reduces file size by encoding the same information more efficiently; lossless methods reconstruct the original data perfectly, while lossy methods permanently discard some data.
- AQA 8525 assesses two lossless methods: run-length encoding (RLE) and Huffman coding.
- RLE replaces consecutive repeated values with a frequency/data pair, so it only saves space when runs are longer than the overhead and can increase size when runs are short, as with ABCABC.
- Huffman coding assigns shorter binary codes to more frequent characters and longer codes to less frequent ones, so frequently used characters consume fewer bits.
- A Huffman code is read as the path from the root down to a character's leaf, with each left branch a 0 and each right branch a 1, and total compressed size is the sum of frequency × code length.
Studying this for an exam?
Generate a personalised learning path for this subject. Free to get started.
Key terms
- Data compression
- Reducing file size by encoding the same information more efficiently.
- Lossless compression
- Compression from which the original data can be perfectly reconstructed, with no data loss, such as RLE and Huffman coding.
- Lossy compression
- Compression in which some data is permanently discarded and cannot be recovered, such as JPEG images and MP3 audio.
- Run-length encoding (RLE)
- A lossless method that replaces consecutive repeated values with a frequency/data pair stating how many times the value appears.
- Frequency/data pair
- The unit of RLE output, written as the count of repetitions followed by the repeated value, such as (8,W).
- Huffman coding
- A lossless method that assigns shorter binary codes to more frequent characters and longer codes to less frequent ones.
- Huffman tree
- A tree that encodes each character's code as the path from the root to its leaf, with left branches as 0 and right branches as 1.
Frequently asked questions
Lossless compression lets the original data be perfectly reconstructed with no data loss, as in RLE and Huffman coding, while lossy compression permanently discards some data and is irreversible, as in JPEG images and MP3 audio.
No. RLE only saves space when data contains long runs of the same value. When runs are short, as in ABCABC, each pair stores one value but adds the overhead of a frequency counter, so the encoded form is larger than the original.
Start at the root and trace the path down to that character's leaf node, reading each left branch as 0 and each right branch as 1. Reading from leaf to root reverses the code, so always start at the root, which is the node at the top with no parent.
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Representing Sound: Sampling Rate and Bit Depth
Software Classification: System Software and Applications
Related lessons
6 min
7 min
6 min