Run-length encoding of a row of coloured pixels
Run-length encoding of a pixel row stores each run of same-coloured pixels as a count then a colour code, in order along the row. E.g. WWWBB becomes 3W2B.
Understanding Run-length encoding of a row of coloured pixels in IGCSE Computer Science Paper 1
What it does: The row is WWWWWBBB. It has two runs, so there are two count and colour code pairs: 5W and 3B. Runs must stay in order along the row. The last B is a separate run after the whites, so it gets its own pair: 1B. Every pixel must be covered. The single blue pixel at the end is a run of length 1, so it needs the pair 1B. Each count says how many pixels are in that run. Add the counts: 5 white + 3 black = 8 pixels. 3W2B and 2B3W add up to the same pixels but are different rows. The order of the pairs rebuilds the row correctly.
Common mistakes: The row should start with three white pixels (W W W), not two. The runs 3 W, 2 K, 4 W and the code 3W2K4W all match the row W W W K K W W W W. The row has four green pixels in a row, so the green run count must be 4, not 3. It should read 'Runs: 2 R, 4 G, 1 B'.
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 86–109) and word search (Modules 86–120).
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 pixel rowFill in the Blanks
Spot the Error
Student with a class code? Join your class →