Ch 3 · 1.3 Data Storage and Compression · O Level Computer Science 2210
Topic 3 of 3 in Data Representation — O Level Computer Science 2210 — 47 lessons.
Introduction
Your phone says a photo is 3.4 MiB and a song 8 MiB. Where do those numbers come from, and how do apps squeeze files to send them faster? (Syllabus section 1.3.)
Key ideas — Measuring storage
In this syllabus, calculations must use 1024, not 1000, and answers must be given in the unit the question asks for.
🧑🏫 Teacher's explanation
Think of data storage like measuring liquid. A single drop is a bit, a small spoonful is a nibble, and a standard cup is a byte. As you collect more, you move to larger containers like liters or gallons. In computer science, we don't use the standard metric system (powers of 1000) for these specific units; instead, we use binary multiples (powers of 1024) because computers operate on base-2 logic.
📖 Definitions
🔍 Worked example — Easy
Convert 3 bytes into bits.
🔍 Worked example — Standard
Calculate the file size of an image with a resolution of 100 × 100 pixels and a colour depth of 8 bits per pixel. Give the answer in bytes.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
Key ideas — Calculating file sizes
Image file size (bits) = resolution (number of pixels) × colour depth (bits per pixel)
🧑🏫 Teacher's explanation
Think of data storage like a massive warehouse. If you are counting small items like screws, you count them individually (bits). If you are counting boxes of screws, you use a larger unit (bytes). As the warehouse gets bigger, you need even larger units like kibibytes or mebibytes to avoid dealing with astronomical numbers. In computer science, we don't use the decimal system (1000) for these jumps; we use the binary system (1024) because computers operate on powers of 2.
📖 Definitions
🔍 Worked example — Easy
Calculate the file size in bytes of a monochrome (1-bit) image with a resolution of 100 × 100 pixels.
🔍 Worked example — Standard
A sound file has a sample rate of 44,000 Hz, a sample resolution of 16 bits, and a duration of 10 seconds. The audio is stereo. Calculate the file size in MiB. (Use 1024 for conversions)
🔍 Worked example — Exam-style
An image has a resolution of 2048 × 1536 pixels and a colour depth of 24 bits. Calculate the file size in MiB. Use 1024 for all conversions.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
Key ideas — Why compress?
Compression reduces the size of a file. Smaller files:
🧑🏫 Teacher's explanation
Imagine you are trying to mail a large, bulky teddy bear to a friend. If you just shove it in a giant box, it takes up a lot of space and costs a lot of money to ship. However, if you vacuum-seal the teddy bear, you squeeze the air out and make it much smaller. It's still the same bear, but it's much easier and cheaper to transport. This is exactly what compression does for digital files.
📖 Definitions
🔍 Worked example — Easy
A student wants to upload a file. Explain two reasons why they should use compression before uploading.
🔍 Worked example — Standard
A digital image is compressed using a lossy method. What is the primary difference between this and lossless compression?
🔍 Worked example — Exam-style
A file is compressed using Run Length Encoding (RLE). If the original sequence of pixels is AAAAABBBCC, what is the compressed version?
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
(a) State one method of compression that would allow the original image to be reconstructed exactly. [1] (b) Explain one disadvantage of using a lossy compression method for this image. [2] [3 marks]
Key ideas — Lossy and lossless compression
Lossy compression reduces file size by permanently removing data. The original file cannot be recovered exactly. Examples: reducing the resolution or colour depth of an image; reducing the sample rate or resolution of sound; removing sounds humans cannot hear (MP3) or detail the eye does not notice (JPEG). Used where a small loss of quality is acceptable (photos, music, video).
🧑🏫 Teacher's explanation
Imagine you are packing for a holiday. If you decide to only pack the essentials and leave your heavy winter coat behind because you know it won't be cold, you have 'lost' something that you can't easily get back without buying a new one—this is like lossy compression. You save space, but the quality of your wardrobe is permanently changed.
📖 Definitions
🔍 Worked example — Easy
A simple text string is represented by the following sequence of characters: ZZZZZAAAAABBB. Apply Run Length Encoding (RLE) to compress this string.
🔍 Worked example — Standard
An image file has a resolution of 100 × 100 pixels. Each pixel is represented by a colour depth of 8 bits. Calculate the uncompressed file size in bits.
🔍 Worked example — Exam-style
A sound file is recorded with a sample rate of 44,100 Hz, a resolution of 16 bits per sample, and a duration of 10 seconds. Calculate the file size in bits.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
Worked example
Example 1: image. An image is 1024 × 768 pixels with a colour depth of 16 bits. Find its size in MiB.
🔍 Worked example — Easy
An image has a resolution of 640 × 480 pixels. Each pixel has a colour depth of 8 bits. Calculate the file size in KiB.
🔍 Worked example — Standard
A mono sound recording is 120 seconds long. It has a sample rate of 8000 Hz and a sample resolution of 8 bits. Calculate the file size in KiB.
⚠️ Common errors
Common mistakes
Practice
Answers: (1) 3 × 1024 × 8 = 24 576 bits. (2) 200 × 100 × 8 = 160 000 bits = 20 000 bytes ÷ 1024 ≈ 19.5 KiB. (3) Any two: less bandwidth used; shorter transmission time; less storage space. (4) Lossy permanently removes data (e.g. reducing an image's colour depth); lossless reduces size with no permanent loss (e.g. run length encoding). (5) 4R 6G 2B 1R.