Run-length encoding: encoding text
Run-length encoding: each run of identical characters becomes a count then the character, so AAAABBB is written 4A3B. A single character is written 1X.
Understanding Run-length encoding: encoding text in Years 9–10 Data & Information
What it does: The lone B is a run of length 1, so it is written 1B. This keeps every run in the same count-then-character format. There are three runs: 2 X's, 3 Y's and 4 Z's. Writing each count and character in order gives 2X3Y4Z. A run is a block of identical characters in a row. WWW, BB and WWWW are three separate runs, even though W appears in two of them. The single B is still a run of length 1, so it must be written as 1B. Leaving it out loses data. The count is the number of characters in the run, which is 12. So the run is written as 12H.
Common mistakes: Run-length encoding writes the count first, then the character. The output should be 4A3B, not A4B3. A single character still needs a count of 1. The lone B must be written 1B, so the output is 5W1B.
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
4A3BFill in the Blanks
Spot the Error
Student with a class code? Join your class →