← ACARA Digital Technologies Years 5–6

Why run-length encoding saves space

Counts each run of one colour instead of listing every pixel. It saves space on long runs, like an all-white row, but saves little when colours change every pixel, like a checkerboard.

Understanding Why run-length encoding saves space in ACARA Digital Technologies Years 5–6

What it does: Counting the numbers in each code shows which one uses less space. The code with fewer numbers is more efficient. A single long run is stored as one count and one colour, so 10 pixels need only 2 values. Long runs of one colour give short codes. The all-white row is just one run of 10. When the colours change every pixel, each run has a count of 1, so you still write as many counts as there are pixels.

Common mistakes: The code 8W says there are 8 white pixels, but the row has only 7 W's. The row should be "WWWWWWWW" so the 2-character code can be compared with an 8-pixel row. A checkerboard row changes colour every pixel, so the run-length code (16 characters) is longer than the row (8). The test should use > to show the code is longer.

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 59–71) and word search (Modules 44–71).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A row has 8 white pixels in a row. Which run-length code stores it with the fewest numbers?
8 white (one count)1 white, 1 white, 1 white, 1 white, 1 white, 1 white, 1 white, 1 white
Matches
A checkerboard row 0 1 0 1 0 1 0 1 is the best row for run-length encoding.
↓
A checkerboard row has no long runs because the colour changes every pixel, so run-length encoding saves almost nothing.
Applying
Meanings
Term
run-length encoding
Meaning
Counts each run of one colour instead of listing every pixel. It saves space on long runs, like an all-white row, but saves little when colours change every pixel, like a checkerboard.
Practice
All-white row: 0 0 0 0 0 0 0 0
Testing
Gaps
RLE: ,0
Check Answer
Spots
1row = "WWWWWWW"
2code = "8W"

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

The 'Woodpecker' badge — Tap Tap Tap, 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. A row has 8 white pixels in a row. Which run-length code stores it with the fewest numbers?
A. 8 white (one count) ✓
B. 1 white, 1 white, 1 white, 1 white, 1 white, 1 white, 1 white, 1 white
An all-white row is one long run, so run-length encoding only needs one count. That is why it saves lots of space.
2. Which row does run-length encoding save the MOST space on?
A. An all-white row of 10 pixels ✓
B. A checkerboard row of 10 pixels
Long runs of one colour give short codes. The all-white row is just one run of 10.
3. A checkerboard row goes black, white, black, white, black, white, black, white. What does run-length encoding do here?
A. It saves almost nothing, because every run is only 1 pixel long ✓
B. It saves lots of space, because there are many colours
When the colours change every pixel, each run has a count of 1, so you still write as many counts as there are pixels.
4. Row A is coded as 1,1,1,1,1,1 and Row B is coded as 6. Which code is shorter?
A. Row A, with 6 numbers
B. Row B, with 1 number ✓
Comparing the length of two codes shows which one saves space. One number is shorter than six.
5. True or false: run-length encoding always makes a picture's code shorter.
A. True
B. False ✓
It only helps when there are long runs of one colour. A checkerboard row can be just as long, or longer, than the original.

Match the Pairs

0 0 0 0 0 0 0 0 → 8 white → An all-white row of 8 pixels can be stored as just 2 values, so run-length encoding saves a lot of space.
0 1 0 1 0 1 0 1 → 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 → A checkerboard row changes colour every pixel, so run-length encoding needs 16 numbers to store 8 pixels and saves nothing.
Compare two codes: a shorter code means the picture is stored using less space. → Row A: 8 numbers | Row B: 2 numbers → Row B is better
Run-length encoding works best on rows with long runs of one colour. → 10 white (a whole row of 10 white pixels)
A checkerboard row 0 1 0 1 0 1 0 1 is the best row for run-length encoding. → A checkerboard row has no long runs because the colour changes every pixel, so run-length encoding saves almost nothing.
All-white row of 8 pixels: 1 white 1 white 1 white 1 white 1 white 1 white 1 white 1 white → The runs were counted one pixel at a time. The whole row is one run, so it should be 8 white.

Key Term

run-length encoding
Counts each run of one colour instead of listing every pixel. It saves space on long runs, like an all-white row, but saves little when colours change every pixel, like a checkerboard.

Fill in the Blanks

1. Row: 00000000 RLE: 8,0
Hint: Type the run length: how many white pixels (0s) are in this all-white row.
2. Row: 0000001111 RLE: 6,0,4,1
Hint: Type the colour digit for the second run, which is the black pixels.
3. Row: 010101 RLE: 1,0,1,1,1,0,1,1,1,0,1,1
Hint: Type the run length that every run has in a checkerboard row, because the colour changes every pixel.
4. pixels = 8 codes = 2 codes < pixels
Hint: Type the comparison operator that shows the RLE code is shorter than the pixel list.
5. pixels = 8 codes = 16 codes > pixels
Hint: Type the comparison operator that shows the RLE code is longer than the pixel list when the colours change every pixel.

Spot the Error

Question 1
A row = "WWWWWWW"
B code = "8W"
C print(len(row))
D print(len(code))
Line A — The code 8W says there are 8 white pixels, but the row has only 7 W's. The row should be "WWWWWWWW" so the 2-character code can be compared with an 8-pixel row.
Question 2
A row = "BWBWBWBW"
B code = "1B1W1B1W1B1W1B1W"
C print(len(code) < len(row))
Line C — A checkerboard row changes colour every pixel, so the run-length code (16 characters) is longer than the row (8). The test should use > to show the code is longer.
Question 3
A row = "WWWWWWWWWW"
B code = "10W"
C print(len(row))
D print(len(row) + len(code))
Line D — The space saved is how much shorter the code is than the row, so you subtract: len(row) - len(code). Adding the lengths would not show any saving.
Question 4
A row = "WWWWBBBB"
B code = "4B4W"
C print(len(row), len(code))
Line B — The row has 4 white pixels and then 4 black pixels, so the runs must be in that order: 4W4B. The broken line has the colours the wrong way around.
Question 5
A row = "WWWWWWWWWWWWWWWW"
B code = "16W"
C print("RLE saves nothing")
Line C — An all-white row is one long run. The code 16W has 3 characters instead of 16, so run-length encoding saves a lot of space.

Student with a class code? Join your class →