Compression Cambridge IGCSE Computer Science revision
Not started
Learn it
In plain words
Compression makes a file smaller, so it takes up less room and travels faster. There are two ways to do it.
Lossy compression throws some of the data away for good, choosing the parts you are least likely to miss. Lossless compression finds a cleverer way to write the same data, so nothing is lost.
6 things to know
- Compression reduces the size of a file.
- A smaller file needs less storage space, less bandwidth to send, and a shorter transmission time.
- Lossy compression permanently removes data. The original file cannot be got back. Examples: reducing the resolution or colour depth of an image, or the sample rate or resolution of a sound.
- Lossless compression reduces file size with no permanent loss of data. The original file can be rebuilt exactly.
- Run-length encoding (RLE) is lossless. It replaces a run of identical values with one copy of the value and a count of how many times it repeats.
- Text and program files must use lossless compression: a missing character or instruction would ruin them.
Worked example
Use run-length encoding to compress the row of pixels WWWWWBBBWW, where W is white and B is black.
- Count each run of the same colour: five whites, three blacks, two whites.
- Write each run as a count and a value: 5W 3B 2W.
- Ten values have been stored as three pairs.
Tips and tricks
- RLE only helps when the same value is repeated many times in a row. On data with few repeats it can make the file bigger.
- For "lossy", write the word "permanently". The point is that the removed data cannot be recovered.
It lands in your notebook with its questions as flashcards.
Compression: 6 questions and answers
These are the quiz’s questions. Do the quiz first, then come back here for the ones that got you.
What is the main purpose of compression?
A smaller file is quicker to send and takes less space.
What does lossy compression do?
The removed data cannot be recovered.
Which file should be compressed using a lossless method?
Every character matters in a text file, so no data may be lost.
What does run-length encoding produce from AAAABBBCCD?
Four As, three Bs, two Cs and one D.
Why is a compressed file quicker to send over a network?
Fewer bits take less time and less bandwidth.
For which data would run-length encoding work badly?Stretch
With few repeated values in a row, there are no long runs to shorten.
Quiz
6 questions
Tap an answer and you’ll see straight away whether it’s right, and why.
Worksheet
3 questions, 6 marks. Write your answers on paper, then check them.
Compression
Cambridge IGCSE Computer Science 0478 · 6 marks · papermunch.org
Name ______________________________ Date ______________
Describe the difference between lossy and lossless compression.[2]
Show answerHide answer
Lossy compression permanently removes some data, so the original cannot be restored. Lossless compression loses no data, so the original file can be rebuilt exactly.
Give two benefits of compressing a video file before it is sent over the internet.[2]
Show answerHide answer
It needs less bandwidth. It takes less time to transmit (or: it takes up less storage space).
Compress WWWWWWBBWWWW using run-length encoding, and state how many pairs are stored.[2]
Show answerHide answer
6W 2B 4W. Three pairs are stored in place of twelve values.
Answers: Compression
- 1. Lossy compression permanently removes some data, so the original cannot be restored. Lossless compression loses no data, so the original file can be rebuilt exactly.
- 2. It needs less bandwidth. It takes less time to transmit (or: it takes up less storage space).
- 3. 6W 2B 4W. Three pairs are stored in place of twelve values.



