Cambridge IGCSE · Topic 1.3
IGCSE Computer Science 0478 / Topic 1 / IGCSE

Smaller files.

Photos, songs and videos are big, and big files are slow to send and fill up storage. Compression makes them smaller, either by throwing away data you are unlikely to miss or by storing the same data more cleverly.

The key idea

Compression reduces the size of a file, so it needs less storage space, less bandwidth and a shorter transmission time. Lossy compression permanently removes data, for example by reducing the resolution or colour depth of an image, or the sample rate or resolution of a sound; the original cannot be recovered. Lossless compression reduces the size without permanent loss of data, so the original file can be rebuilt exactly; run length encoding (RLE) is an example.

run length encoding (RLE) of one row of 15 pixels 8 white3 black4 white 8 W3 B4 W 15 values become 3 pairs: lossless, the row can be rebuilt exactly
Fig. 1: RLE stores each run of identical values as a count and the value
Section 01

Why compress?

Smaller files help everyone who stores or sends them. Learn the three benefits the syllabus names.

Examiner trap

"It makes the file smaller" only restates compression. For a mark, give the effect: less storage, less bandwidth or a shorter transmission time.

Section 02

Lossless: run length encoding.

In the lab, type some text or paint a 1-bit image and watch RLE replace each run of identical values with a count and the value. Then decode it again.

Worked example Encode and count
Use RLE to encode WWWWWWWWBBBWWWW. If each count and each character take 1 byte, how many bytes are saved?
  1. Runs: 8 W, then 3 B, then 4 W.
  2. Encoded: 8W 3B 4W, which is 3 pairs = 6 bytes.
  3. Original: 15 characters = 15 bytes.
  4. Saved: 15 − 6 = 9 bytes.
Answer: 8W 3B 4W; 9 bytes saved
Your turn
Decode the RLE data 3R 2G 5B.
Examiner trap

RLE does not always make a file smaller. ABCD encodes as 1A 1B 1C 1D, which is twice as long.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is lossless compression?

Quick check+10 XP

Which of these is an example of lossless compression?

Quick check+10 XP

Why can a file compressed with lossy compression not be restored to the original?

Quick check+10 XP

In the lab, why does RLE make the text ABCDEF bigger?

Section 03

Lossy: data is gone.

Switch the lab to lossy mode and reduce the resolution, colour depth or sample rate. The file shrinks, but undoing it cannot bring back the detail.

LossyLossless
Datapermanently removednone permanently lost
Original recovered?noyes, exactly
Methodsreduce image resolution or colour depth; reduce sound sample rate or resolutionrun length encoding (RLE)
File sizeusually much smallersmaller, but usually less reduction
Suitsphotos, music and video, where small losses are hard to noticetext, program code, spreadsheets, where every bit matters
Examiner trap

Never choose lossy compression for text or program files: a lost character or instruction changes the meaning or stops the program working.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

Which is a lossy compression method for an image?

Exam style+20 XP

Which is a benefit of compressing a file before sending it?

Exam style+20 XP

What is the RLE encoding of GGGGGHHH?

Exam style+20 XP

Which file should be compressed with lossless compression?

Skill unlocked

Compression, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Why files are compressed, lossy and lossless methods, and run length encoding.