1. Data storage and File compression
IGCSE Computer Science (0478)
  • Data Representation
    • Introduction
    • Why computers use binary (how binary represents data)
    • Number system
      • Introduction
      • Number Conversions
      • Addition of Binary Numbers
      • Logical binary shifts (positive 8-bit integers)
      • Two’s Complement (Signed: Positive and Negative Numbers)
      • Use of the Hexadecimal System
    • Text, Sound and Image
      • Text, Sound and Images
      • File Types
    • Data storage and File compression
      • Measurement of the Size of Computer Memories
      • Lossless and Lossy File Compression
  1. Data storage and File compression

Lossless and Lossy File Compression

Lossless Compression#

Lossless compression means the file gets smaller but no information is lost.
When you open the file again, it looks exactly the same as the original.
This is important for files like homework, documents, or spreadsheets where losing any data can cause problems.
It works by finding repeated patterns and storing them in a shorter way.

Example: Run-Length Encoding (RLE)#

Imagine you have a string of letters:
aaaaabbbbccddddd
Instead of writing all letters again, we say:
“5 times ‘a’, 4 times ‘b’, 2 times ‘c’, 5 times ‘d’”
So it becomes:
5 a 4 b 2 c 5 d
This takes less space because we write the letter only once with how many times it repeats.
But if the letters don’t repeat like cdcdcdcdcd, RLE doesn’t help much.
To fix this, a special flag number (like 255) is added to show repeated parts.

Lossy Compression#

Lossy compression makes the file smaller by removing some details that we may not notice.
You cannot get the original file back exactly after compressing.
This is used for photos, music, and videos where small loss of quality is okay.
It reduces things like picture sharpness or sound quality to save space.

Example:#

When you save a photo as a JPEG, the computer removes some tiny colour details.
The picture becomes smaller but still looks good to our eyes.
MP3 music files remove sounds you probably won’t hear, making the file smaller.

Summary Table#

Compression TypeData LossExample UsesHow it Works
LosslessNoDocuments, SpreadsheetsFinds repeated data and shortens
LossyYesPhotos, Music, VideosRemoves less important details
Lossless and Lossy File Compression - visual selection.png

Absolutely! Here’s a simple practice quiz for your students based on the section — perfect for Class 10:

Practice Questions on File Compression#

1.
What is the main difference between lossless and lossy compression?
2.
Why is lossless compression important for files like spreadsheets?
3.
Give an example of where lossy compression is used.
4.
Look at this string: aaaaaaabbbbcc
How would Run-Length Encoding (RLE) compress this?
5.
If a JPEG photo loses some colour details to reduce size, is this lossless or lossy compression?
6.
True or False: After lossy compression, you can get the exact original file back.

Answers#

1.
Lossless compression keeps all the data and nothing is lost; lossy compression removes some data to make files smaller.
2.
Because losing any data in a spreadsheet can cause errors or problems.
3.
Photos (JPEG), music (MP3), and videos (MP4).
4.
7 a 4 b 2 c
5.
Lossy compression.
6.
False.
Modified at 2025-08-11 07:24:26
Previous
Measurement of the Size of Computer Memories
Built with