KwickAcademy Computer Systems · 5 min · free
Data Compression: Lossy and Lossless
Learn why we compress files, how lossless compression and run length encoding work, and what lossy compression removes. Lossless gives back the exact original file; lossy removes some data for good.
Follows the syllabus of: Cambridge IGCSE Grade 9 Computer Science (0478), Cambridge IGCSE Grade 10 Computer Science (0478), Edexcel GCSE GCSE Computer Science (1CP2)
On screen in this lesson
What is compression?
| Compression makes a file smaller |
| It stores the same data using fewer bits |
| Decompression opens it back for use |
Why we compress files
| Uses less storage space |
| Uploads and downloads faster |
| Uses less mobile data and bandwidth |
| Makes streaming video and music possible |
Two types
| Type | Data lost? | Original back? |
|---|---|---|
| Lossless | no | yes, exactly |
| Lossy | yes, some | no, only close |
Lossless compression
| Finds patterns and repeats in the data |
| Stores them in a shorter way |
| Every bit comes back exactly |
| Used for text, programs, ZIP and PNG files |
Run length encoding
| Data | RLE form | Size |
|---|---|---|
| WWWWWWBBBWWWW | 6W 3B 4W | 13 to 6 |
| AAAAAAAA | 8A | 8 to 2 |
| ABCD | 1A 1B 1C 1D | 4 to 8 |
Pause and predict
| A row of pixels: RRRRRGGB |
| What is its RLE form? |
Quick answers
What is the RLE form of RRRRRGGB?
5R 2G 1B.
Why must an app use lossless compression?
Even one wrong bit can stop it working.
KwickClips from this lesson
Short clips, one idea each. Good for revision the night before.
What does compression do to a file?39 sec
What does RLE store for each run?43 sec
Can lossy removed data be brought back?42 sec
Can you use lossy compression for an app?42 secThe full lesson, in text
Hello students, welcome to Kwickprep. When you send a photo on a chat app, it arrives in seconds, but it is often a little less sharp. What happened to it? Today we will learn why we compress files, how lossless and lossy compression work, and how to choose between them.
Let us start with the meaning. Compression makes a file smaller. It stores the same data, or almost the same data, using fewer bits. Decompression is the reverse step, which opens the file back so we can use it.
Why do we compress files? First, a smaller file uses less storage on your phone or computer. Second, it uploads and downloads faster. Third, it uses less mobile data and less bandwidth, which is how much data a connection can carry each second. Finally, streaming video and music online would be too slow without compression.
There are two types of compression. Lossless compression loses no data, so decompressing gives back the exact original file. Lossy compression removes some data for good, so we get back a file that is close, but not the same.
Let us look at lossless compression first. It looks for patterns and repeated data. It then stores those repeats in a shorter way. When we decompress, every single bit comes back exactly. So it is used for text, program files, ZIP folders and PNG images.
One simple lossless method is run length encoding, or RLE. A run is a group of the same value in a row. RLE stores each run as a count and the value. So six whites, three blacks and four whites become six W, three B, four W, which is thirteen characters down to six. Eight As become just eight A. But A B C D has no runs, so RLE makes it bigger, eight characters instead of four.
Some exams ask how RLE data is read back. The outer loop goes through each count and value pair. The inner loop repeats as many times as the count. Each time, it outputs the value. So the pair six W outputs W six times.
Pause and predict. A row of pixels is five reds, two greens and one blue. What is its RLE form? It is five R, two G, one B.
Now, lossy compression. It removes data that people are unlikely to notice. That removed data is gone for good, and cannot be brought back. In return, the file becomes much smaller than lossless can make it. But if we compress too much, the picture shows blocks or the sound gets noisy.
Here is lossy compression in files you use daily. JPEG images remove fine colour detail, because our eyes notice brightness more than small colour changes. MP3 and AAC audio remove sounds too high or too quiet for humans to hear, using perceptual coding based on psychoacoustics. MP4 video does not store the unchanged parts of each frame again, and removes detail we will not notice. That is why a two hour movie can fit in a small download.
So how do we choose? A program must use lossless, because even one wrong bit can stop it working. A text document or marksheet must be lossless, because every character counts. A medical scan is kept lossless, because a small detail may matter to a doctor. A holiday photo can be lossy, since it is much smaller and still looks the same. A streaming song can be lossy too, so it plays fast on less data.
Here is one rule for exam answers. If the exact original must come back, choose lossless. If a small size matters more than tiny details people cannot notice, choose lossy. Always give the reason, not just the type.
Let us revise what we learned today. Compression saves storage, transfer time and mobile data. Lossless compression loses nothing, so the exact original comes back. Run length encoding stores each run as a count and a value. Lossy compression removes data we will not notice, and it is gone for good. Choose lossless when the exact original is needed, and lossy when size matters more.
Courses that teach this
| Course | Unit |
|---|---|
| Cambridge IGCSE Grade 9 Computer Science (0478) | 1. Data Representation |
| Cambridge IGCSE Grade 10 Computer Science (0478) | 1. Data Representation |
| Edexcel GCSE GCSE Computer Science (1CP2) | Topic 2: Data |
Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.
Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

