When run-length encoding makes data bigger
When data has few repeats, run-length encoding adds a count to every character, so the result can be longer than the original. It only saves space when the data has long runs.
Understanding When run-length encoding makes data bigger in Years 9–10 Data & Information
What it does: The encoded length equals the original length here, so RLE saved no space at all. Short runs of 2 only break even. Long runs suit RLE because 12 characters become just 3. Data with few repeats needs a different technique. RLE stores each run as a count plus the character. A dictionary is a different technique (substitution compression). Long runs are the best case. The first string becomes 12W4B, which is much shorter. The alternating string has 16 runs of length 1, so it becomes longer. The original ABAB has 4 characters. The encoded version has 8, so the data doubled in size. This is the worst case for RLE.
Common mistakes: The encoded text 1A1B1C1D1E1F has six different letters, so the data must be ABCDEF with no repeats. AAAAAA would encode to just 6A, so line 1 should be data ← ABCDEF. The encoded text 10A is 3 characters long (1, 0 and A), not 2. Line 4 should be encoded_length ← 3. This is the best case, because one long run shrinks 10 characters to 3.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 6–16) and word search (Modules 6–132).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
RLE expansionFill in the Blanks
Spot the Error
Student with a class code? Join your class →