Keep it or lose it.

Six original Cambridge-style questions on compression and run-length encoding, with worked solutions.

Original questions All questions on this page are original work, written in the Cambridge AS & A Level style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Exact or close enough.

01
Explain
[2 marks]

Explain why files are often compressed before they are sent across the internet.

  • The file is smaller, so less bandwidth is needed. ✓
  • It is transmitted / downloaded faster (also accept: uses less storage on the server). ✓
02
Apply
[3 marks]

A text file contains XXXXXXYYZZZZZZZZZW. Each character and each count is stored in 1 byte. (a) Show the result of run-length encoding. (b) Calculate the number of bytes saved.

  • (a) 6X 2Y 9Z 1W. ✓
  • Original 18 bytes; encoded 4 pairs = 8 bytes. ✓
  • (b) 18 − 8 = 10 bytes saved. ✓
03
Apply
[4 marks]

A music streaming service and a hospital both need to compress image and sound files. Justify the type of compression each should use.

  • Streaming service: lossy. ✓
  • Much smaller files stream quickly with less bandwidth; the removed data is not noticed by most listeners. ✓
  • Hospital: lossless. ✓
  • Medical images and recordings must be restored exactly, as lost detail could affect a diagnosis. ✓
04
Explain
[3 marks]

Describe how a sound file can be compressed using lossy compression.

  • Perceptual coding / psychoacoustics is used. ✓
  • Frequencies outside the range of human hearing are removed. ✓
  • Quieter sounds that are masked by louder sounds at the same time are removed (also accept: reduce the sampling rate or resolution). ✓
05
Explain
[3 marks]

Explain how a text file can be compressed, and why only lossless compression is suitable.

  • Runs of repeated characters can be replaced by a count and the character (RLE). ✓
  • Repeated words or phrases can be replaced by short codes, with a dictionary of codes stored in the file. ✓
  • Lossless is needed because every character must be restored exactly; losing any would change the meaning. ✓
06
Analysis
[3 marks]

A 1-bit image row is 10101010. It is compressed with RLE, storing each run as a (count, colour) pair. Explain the effect on the size of the data and state what type of image RLE suits.

  • Every run has length 1, so the row becomes 8 pairs: (1,1)(1,0)(1,1)(1,0)(1,1)(1,0)(1,1)(1,0). ✓
  • 16 values are stored instead of 8, so the data gets larger. ✓
  • RLE suits images with large areas of the same colour (long runs), such as simple diagrams or logos. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.