📁 Topic 3 · 3.3 Sound and Compression
3.3b Data compression — lossy, lossless and RLE
Edexcel 4CP0 · iGCSE Computer Science · ~12 min read
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

Why Compress Data?

Data compression reduces the size of files so that they take up less storage space and can be transmitted faster over networks. Compression is essential for streaming video, sending email attachments, and storing large image libraries.

Lossy Compression

Lossy compression permanently removes some data from the file to reduce its size. The original file cannot be perfectly reconstructed — some quality is lost, but the file becomes significantly smaller. This is acceptable when humans cannot easily detect small quality reductions.

  • Examples: MP3 (audio), JPEG (images), MPEG/MP4 (video)
  • Technique: removes frequencies humans cannot easily hear (in audio) or reduces colour detail in smooth areas (in images)
  • Advantage: very high compression ratios
  • Disadvantage: quality degrades; original cannot be recovered; repeated compression makes it worse

Lossless Compression

Lossless compression reduces file size without losing any data. The original file can be perfectly reconstructed by decompressing. Used when exact data preservation is essential.

  • Examples: PNG (images), GIF (images), FLAC (audio), ZIP (archive)
  • Advantage: original data fully restored after decompression
  • Disadvantage: lower compression ratio than lossy
  • Best for: text files, programs, medical images, legal documents

Run-Length Encoding (RLE)

Run-Length Encoding is a simple lossless compression algorithm. It replaces consecutive repeated values (a "run") with a count and the value. Very effective for images with large areas of the same colour.

Example: Compress the pixel sequence AAABBCCCCDDDDDD

Original: A A A B B C C C C D D D D D D
Compressed: 3A 2B 4C 6D

Original: 15 characters
Compressed: 8 characters (pairs: count + value)

RLE works best when there are many repeated consecutive values. It performs poorly (or even makes files larger) when there are few runs — e.g. a checkerboard pattern like ABABAB.

Lossy vs Lossless

FeatureLossyLossless
Data lost?Yes — permanentlyNo — fully recoverable
File size reductionVery highModerate
Best forMedia (audio, video, images) where small quality loss acceptableText, programs, data where accuracy is critical
ExamplesMP3, JPEG, MP4FLAC, PNG, ZIP, GIF
📝 Exam Tip: When asked to explain RLE, always trace through the worked example. Show the original data, then the compressed version with counts. Explain when RLE is effective (long runs) and when it is not (varied data with no repeats).
⚠️ Common Mistakes
  • Saying lossless "compresses better" than lossy — it does NOT; lossy achieves much smaller files
  • Saying data "is lost" in lossless — no data is lost; that's the defining feature
  • Applying RLE to non-repeating data without noting it may increase file size
← 3.3a Representing Sound Topic 3 · 3.3 Sound and Compression Next: 3.4 Encryption →
🔒
Pro Content
Subscribe to access all 47 Edexcel iGCSE lessons.
£7.99/month
or £59/year