ScholaFly

CS03-05 Computer Science Watch

Why we compress data

Watch on YouTube

In this lesson

In this video you'll learn about why we compress data for GCSE Computer Science.

By the end: Explain what data compression is and why data is compressed, and - on the two boards that use the words - compare lossless and lossy compression, giving an advantage, a disadvantage and a suitable use for each, with a justification that says why rather than how.

What it covers

  1. 1:04 Why we compress data: compression means making a file take up
  2. 7:23 Choosing between the two is a question about the file

Key words

About this video

Why We Compress Data (Lossless vs Lossy) | GCSE Computer Science

Why data is compressed, and how lossless and lossy compression compare, with how to justify which suits a file.
AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Images and sound 5 of 7.
Full Images and sound playlist: https://www.youtube.com/playlist?list=PLAonf4a5MXts
More at https://scholafly.com

Watch first: GCSE Computer Science - Working out image and sound file sizes | Images and sound 4/7 - https://youtu.be/_CcijC_0L1U
Video code: CS03-05 (search "ScholaFly CS03-05")

Videos in this chapter:
CS03-00 Images, sound and compression - Intro: https://youtu.be/5_VNvpWBbVU
CS03-01 How an image is stored: https://youtu.be/HKb8YHkv23c
CS03-02 From binary to bitmap and back: https://youtu.be/D7AjvZoKT_M
CS03-03 How sound is stored: https://youtu.be/LOCcQaN-_fI
CS03-04 Working out image and sound file sizes: https://youtu.be/_CcijC_0L1U
CS03-05 Why we compress data: https://youtu.be/ylXSh7OO4dI
CS03-06 Huffman coding: https://youtu.be/ig0uHFLoc9U
CS03-07 Run length encoding

#GCSEComputerScience #ImagesAndSound #DataCompression

For teachers
This GCSE Computer Science lesson teaches why we compress data. By the end, students should be able to explain what data compression is and why data is compressed, and - on the two boards that use the words - compare lossless and lossy compression, giving an advantage, a disadvantage and a suitable use for each, with a justification that says why rather than how. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.

Exam board specification references:
AQA GCSE Computer Science (8525)
- 3.3.8 Data compression
Pearson Edexcel Level 1/Level 2 GCSE (9-1) in Computer Science
- 2.3.2 Explain the need for data compression and compare lossless and lossy methods.
Cambridge OCR Level 1/Level 2 GCSE (9-1) in Computer Science
- 1.2.5 Explain why compression is needed and compare lossy and lossless compression.

Read the transcript

Picture a song playing on a streaming app. Before it reached you, a large part of its data was thrown away for good, and almost nobody listening can tell. Somebody chose which parts to drop, betting that your ears would not miss them. That is a bargain, and it is only a good one if you know what was handed over. Make the same bargain with a legal contract or a program file, and a lost word or byte never comes back. By the end of this video you can say which files get which deal, and why. It starts with why anyone makes a file smaller at all.

We are at video five of seven now. This one leans on the sizes from Working out image and sound file sizes, so start there if those sums feel unsteady.

Compression means making a file take up fewer bits than it did. A compressed file is the smaller version, made in a way that can be undone or lived with. There are several reasons to do it. A smaller file uses less storage space. It downloads and sends faster. It uses less bandwidth, which is how much data a connection can carry each second. And it can fit under a limit, such as the biggest attachment an email allows. Streaming is the same story: a smaller file arrives fast enough to play without stopping. Every course asks what compression is and why it is done, so this first part is for everyone. After that the courses split, and the video says which part is whose as it goes. A photo will not attach to an email, because the email system has a size limit for attachments. How does compressing the photo help? Give both steps of the reasoning. Compression makes the file smaller, and that means it fits within the limit, so it can be sent. One examiner's report records answers that stopped halfway. Many students gave a response that it would mean the compressed file could be attached to an email, without explaining that the compression would mean the file size would be within the limit for attachments. The fix is a two-part answer every time: what changes, and what that change then allows. The file gets smaller, and that means it fits.

A student writes that a compressed file cannot be read until it is uncompressed, and that compression scrambles the data so nobody can read it. What is wrong with each half of that student's claim? Both halves are wrong. Shrinking a file does not stop it opening as normal, and scrambling for privacy is a different job, called encryption. A compressed photo still opens and still looks like a photo, and a compressed document still reads. And compression is not encryption: compression changes how much room the data takes, while encryption changes who can read it. That is its own video, Encryption across a network. One examiner's report records the first belief. A common incorrect answer was that the data would not be readable, or understandable, after compression. The fix is to keep three words apart: smaller, damaged and hidden. Compression only ever means smaller.

Two courses split compression into two types. Lossless compression makes a file smaller without losing any data, so the original can be rebuilt exactly, bit for bit. Lossy compression makes a file smaller by removing some data permanently, so the original can never be rebuilt. The word lossy has loss inside it, and lossless loses none. A file is compressed, sent, and opened again, and it matches the original bit for bit. Which type of compression was used, lossy or lossless, and how can you tell? Lossless. Only lossless gets back every bit, because nothing was thrown away; lossy could never match the original. One examiner's report records the swap. Some candidates confused lossless compression with lossy compression. Another report records a strength. Many students showed a good understanding of lossy compression, particularly with regards to permanent data loss. The permanent loss is the part students hold on to. The fix for the swap is to read the word itself: lossy is the one with loss in it. The third course never uses the words lossy or lossless. It names two methods instead, Huffman coding and run length encoding, which are the next two videos, so on that course this part is background. Each type has a cost. Lossy gives a much smaller file and a higher compression ratio, meaning it shrinks the file by more, but the lost quality is permanent. Lossless keeps everything, so it cannot shrink a file as far. A music file is compressed with lossy compression. Name a benefit and a drawback of choosing lossy for that music file. Advantage: the file is much smaller, so it downloads and streams faster and takes less storage. Disadvantage: some sound is lost for good, so it can never be restored to the original quality. Lossy audio can remove sounds outside the range of human hearing, which nobody would notice. That is the bargain the song on the streaming app was making.

Choosing between the two is a question about the file. So the justification says why the type suits that file, not how the compression works. A sentence that does the job: lossy suits this file because the loss will not be noticed and the smaller size matters more. Or: lossless suits this file because every bit must come back. A company must compress two folders. The first holds legal documents; the second holds holiday photographs. Which type suits each folder, and why is it the right fit? Lossless for the legal documents, because a lost word could change what the contract means. Lossy for the photographs, because the eye will not miss the discarded detail and the smaller files matter. Now a weaker answer for the photographs: lossy compression removes some of the data and approximates similar colours. Why does that answer not justify the choice? It explains the method, not the reason. A justification says why the type fits these pictures: nobody will notice what went, and the smaller files matter more. One examiner's report names that swap of how for why. However, often candidates could not justify it appropriately, for example by describing how it would be compressed instead of why this was appropriate. The fix is the because sentence: this type suits this file because of something about the file. One course even says outright that carrying out a compression method is not required. Neither type wins outright. Lossless keeps everything, and that is also why it cannot make a file as small as lossy can. The file decides. That is why streaming chose lossy for music: ears were the judge, and smaller files play without stopping. A contract never gets that deal.

Four short questions, and the last one returns to the song on the streaming app. In one sentence, what does compressing a file mean? Making a file take up fewer bits than it did. Next, a file not seen yet. A program is compressed to send it: lossy or lossless, and why? Lossless, because a program needs every byte back as it was, or it may not run. Now a video for a website. Why lossy, in a two-part answer? Lossy makes the file much smaller, and that means it loads and streams faster for visitors, with little loss anyone can see. One more, back to the song on the streaming app. What was handed over in that bargain? Some of the song's data, gone for good. In return the file got much smaller, and the loss sits where ears do not notice it.

No need to see this twice if you could pick lossy or lossless for any file and back it with a because, so press the thumb on this one. If the two types still swap places in your head, save it; the next two videos keep coming back to why files shrink, so this comes round again.

Next in the chapter: Huffman coding.

For more, visit scholafly.com, or watch the next video.

Related terms

For: AQA GCSE 8525, Edexcel GCSE 1CP2, OCR GCSE J277

On the specification

BoardSpecStatement
AQA GCSE 85253.3.8Data compression
Edexcel GCSE 1CP22.3.2Explain the need for data compression and compare lossless and lossy methods.
OCR GCSE J2771.2.5Explain why compression is needed and compare lossy and lossless compression.
For teachers

This GCSE Computer Science lesson teaches why we compress data. By the end, students should be able to explain what data compression is and why data is compressed, and - on the two boards that use the words - compare lossless and lossy compression, giving an advantage, a disadvantage and a suitable use for each, with a justification that says why rather than how. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.