GCSE Computer Science • Data Representation

Compression

Learn why and how we compress files, understand lossy vs lossless compression, and practice RLE and dictionary encoding.

0
Activities
0
Correct
0
Streak 🔥

Key Concepts

Understanding why and how we compress data

Why Compress Files?

💾 Reduce Storage

Store more files on your device. E.g., compress music to fit more songs on your phone.

🌐 Faster Transfer

Reduce transmission time over networks. E.g., upload images faster to social media.

🔒 Lossless Compression

  • Original file can be perfectly reconstructed
  • No quality loss at all
  • Generally smaller compression ratio
  • Good for text, code, documents
  • Examples: ZIP, PNG, PDF, FLAC
ZIP PNG PDF FLAC

⚠️ Lossy Compression

  • Original file cannot be reconstructed
  • Removes data imperceptible to humans
  • Much higher compression ratios
  • Good for images, audio, video
  • Repeated compression degrades quality
JPEG MP3 MP4 WEBP
Run Length Encoding (RLE)
Replaces sequences of repeated values with a count and the value. E.g., "AAAABBB" becomes "4A3B". Best for data with long runs of the same value.
Dictionary Encoding
Builds a dictionary of repeated patterns and replaces them with shorter codes. E.g., "the" appearing 10 times gets replaced with "1".
Negative Compression
When the "compressed" file is actually larger than the original. Happens when data has few repeated patterns.
Quality Degradation
With lossy compression, repeatedly saving a file causes cumulative quality loss. Each save removes more data.
📊
File Types and Compression
File Type Recommended Reason
Text files Lossless Every character matters
Executable files Lossless Code must be exact or program won't work
Documents Lossless Data integrity is essential
Photos Lossy (usually) Human eye won't notice small changes
Music Lossy (usually) Human ear won't notice removed frequencies
Video Lossy Huge files need significant compression

Run Length Encoding

Create pixel art and see how RLE compresses it

🔢
RLE Simulator

Click cells to paint them. Watch how Run Length Encoding compresses each row by counting consecutive colours.

📊 RLE Encoded Output

0
Original (bits)
0
Compressed (bits)
0%
Compression

Dictionary Encoding

See how repeated words are replaced with shorter codes

📖
Dictionary Encoder

Enter text below to see how dictionary encoding compresses it by replacing repeated words.

Memory Match

Match compression concepts with their descriptions

🧠
Find the Pairs

Match each compression term with its correct description.

Categorize

Sort file types and characteristics into Lossy or Lossless

📂
Lossy vs Lossless

📦 Drag items from here:

Knowledge Check

Test your understanding with these exam-style questions