0984

Data Storage and Compression

Data Representation · 4 question types

Exam Frequency Analysis

Past paper frequency (2018 to 2024)

This topic accounts for approximately 4% of your exam marks.

stable
Rare
Stable4%

File size calculations and lossless vs lossy compression are regular 3 to 4 mark questions.

RLE is a simple lossless method that works well on data containing long runs of the same value repeating in a row.

How RLE works

  1. Walk through the input one value at a time.
  2. Whenever you find a run of the same value repeating, count how many times it occurs.
  3. Replace the whole run with a single (count, value) pair.
  4. Continue to the next value (or run) and repeat.

The decoder reverses this by expanding each pair back into count copies of value.

When RLE works well, and when it does not

RLE is only effective if the data has long runs:

  • Works well: scanned line art, simple icons, large patches of uniform colour in a bitmap, faxes.
  • Works poorly: natural photographs (almost every pixel is slightly different from its neighbour), high-frequency audio, already-compressed data, encrypted data.

In the worst case, RLE can actually increase the file size: if every value is different from the next, each value becomes a 1-value run, so the output is roughly twice the original size.

RLE is lossless

The decoded data is bit-identical to the original. RLE counts as lossless because expanding each (count, value) pair back to count copies of value perfectly restores the input.