← Years 9–10 Data & Information

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.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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.

Learning
Duo
Which string will run-length encoding make LONGER?
ABCDEF (encodes to 1A1B1C1D1E1F)AAAAAA (encodes to 6A)
Matches
RLE always makes data smaller, so ABCDEF → 1A1B1C1D1E1F is shorter
↓
The encoded string has 12 characters, which is longer than the original 6. RLE only saves space when there are long runs.
Applying
Meanings
Term
RLE expansion
Meaning
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.
Practice
Best case: AAAAAAAAAA -> 10A
Testing
Gaps
ABC encodes to A1B1C
Check Answer
Spots
1data ← AAAAAA
2encoded ← 1A1B1C1D1E1F

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Kangaroo Rat' badge — Speed Typer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which string will run-length encoding make LONGER?
A. ABCDEF (encodes to 1A1B1C1D1E1F) ✓
B. AAAAAA (encodes to 6A)
ABCDEF has no repeats, so every letter gets a count added. 6 characters become 12. AAAAAA is one long run, so it shrinks from 6 characters to 2.
2. What does run-length encoding add for each run of characters?
A. A dictionary that stores the repeated words
B. A count showing how many times the character repeats ✓
RLE stores each run as a count plus the character. A dictionary is a different technique (substitution compression).
3. Which data is the BEST case for run-length encoding?
A. WWWWWWWWWWWWBBBB (a few very long runs) ✓
B. WBWBWBWBWBWBWBWB (alternating letters)
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.
4. The string ABAB is encoded with RLE as 1A1B1A1B. What happened to the size?
A. It shrank from 8 characters to 4
B. It grew from 4 characters to 8 ✓
The original ABAB has 4 characters. The encoded version has 8, so the data doubled in size. This is the worst case for RLE.
5. Why can RLE make data bigger?
A. A count is added to every run, even runs of length 1 ✓
B. RLE deletes characters that look the same
Every run gets a count. When most runs are only 1 character long, the counts add extra characters instead of saving any. RLE never deletes data.

Match the Pairs

AAAAAAAA → 8A → Best case for RLE: one long run shrinks from 8 characters to 2
ABCDEF → 1A1B1C1D1E1F → Worst case for RLE: no repeats, so the encoded data doubles from 6 to 12 characters
Comparing lengths shows whether RLE helped: the encoded text must be shorter than the original → AABBCC (6) → 2A2B2C (6)
Choose a technique to suit the data: use RLE for data with long runs, such as a plain white image row → WWWWWWWWWWWW → 12W
RLE always makes data smaller, so ABCDEF → 1A1B1C1D1E1F is shorter → The encoded string has 12 characters, which is longer than the original 6. RLE only saves space when there are long runs.
ABAB → 2A2B (encoded is shorter, so RLE worked) → RLE counts consecutive repeats only. ABAB has no runs, so the correct encoding is 1A1B1A1B, which is twice as long.

Key Term

RLE expansion
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.

Fill in the Blanks

1. ABC encodes to 1A1B1C
Hint: Type the count RLE gives to a character that appears only once.
2. IF encodedLen > originalLen THEN OUTPUT "RLE made it bigger" END IF
Hint: Type the comparison operator meaning the encoded data is longer than the original.
3. AAAAAAAAAA -> 10A (3 chars)
Hint: Type the count for this long run of A characters.
4. RLE saves space when data has long runs
Hint: Type the word for a block of the same character repeated.
5. Original: ABCDEF, length 6 Encoded: 1A1B1C1D1E1F Encoded length: 12
Hint: Type the length of the encoded string, counting every digit and letter.

Spot the Error

Question 1
A data ← AAAAAA
B encoded ← 1A1B1C1D1E1F
C original_length ← 6
D encoded_length ← 12
Line A — 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.
Question 2
A data ← AAAAAAAAAA
B encoded ← 10A
C original_length ← 10
D encoded_length ← 2
Line D — 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.
Question 3
A data ← ABAB
B encoded ← 1A1B1A1B
C encoded_length ← 4
D original_length ← 4
Line C — 1A1B1A1B has 4 runs, and each run needs 2 characters (a count and a letter), so the encoded length is 8. Line 3 should be encoded_length ← 8, which is double the original 4.
Question 4
A data ← WWWWWWWWBB
B encoded ← 8W1B
C IF encoded shorter THEN
D use RLE
Line B — The data ends with two B characters, so the second run is 2B, not 1B. Line 2 should be encoded ← 8W2B.
Question 5
A IF runs are short THEN
B RLE saves space
C ELSE RLE may make it bigger
Line A — RLE saves space when the runs are long. Short runs are the case where it can make data bigger, which is what the ELSE line says. Line 1 should be IF runs are long THEN.

Student with a class code? Join your class →