Home Notes Papers

Data storage and compression

Paper 1

This section is examined in Paper 1.

Measuring Data Storage
Data storage units are based on the binary system (base 2), not the decimal system (base 10). This is because computers use bits (0s and 1s). The fundamental unit is the bit.

A byte consists of 8 bits. Larger units are defined using powers of 2, specifically 2^{10}, which equals 1024. It is critical to distinguish between binary prefixes (used in computing) and decimal prefixes (used in some storage marketing).

The standard binary prefixes are:

  • Kibibyte (KiB): 2^{10} bytes = 1024 bytes.
  • Mebibyte (MiB): 2^{20} bytes = 1024 KiB.
  • Gibibyte (GiB): 2^{30} bytes = 1024 MiB.

Note: In many Cambridge contexts, 'KB' is often used loosely to mean Kibibyte (1024 bytes), but strictly speaking, KB can mean 1000 bytes in decimal. Always check the context or use KiB/MiB/GiB for clarity. However, for calculation purposes in this syllabus, always use 1024 as the multiplier/divisor between standard storage units (KB, MB, GB).

UnitDefinition (Binary)Equivalent in Bytes
BitSmallest unit of data1/8 byte
Byte (B)8 bits1 B
Kilobyte (KB/KiB)2^{10} bytes1024 B
Megabyte (MB/MiB)2^{20} bytes1,048,576 B
Gigabyte (GB/GiB)2^{30} bytes1,073,741,824 B
File Size Calculation
To calculate the size of a digital file, you must determine the total number of bits required to represent all the data. The general formula is:

\text{Total Bits} = \text{Number of Elements} \times \text{Bits per Element}

Where:

  • Number of Elements: For images, this is the total number of pixels (Width \times Height). For sound, this is the total number of samples (Sample Rate \times Duration).
  • Bits per Element: This depends on the resolution or depth.
    • For images, bits per pixel is determined by the colour depth (e.g., 8-bit colour means 8 bits per pixel). If colour depth is given in bytes, multiply by 8 to get bits.
    • For sound, bits per sample is determined by the bit depth (e.g., 16-bit audio means 16 bits per sample).

Once you have the total bits, convert to Bytes by dividing by 8. Then convert to KB, MB, etc., by dividing by 1024 repeatedly.

Calculating Image File Size
Question: Calculate the file size in Kilobytes (KB) of an uncompressed image with a resolution of 1024 \times 768 pixels and a colour depth of 24 bits.

Step 1: Calculate total pixels.
\text{Pixels} = 1024 \times 768 = 786,432 \text{ pixels}

Step 2: Calculate total bits.
The colour depth is 24 bits per pixel.
\text{Total Bits} = 786,432 \times 24 = 18,874,368 \text{ bits}

Step 3: Convert to Bytes.
\text{Bytes} = \frac{18,874,368}{8} = 2,359,296 \text{ bytes}

Step 4: Convert to Kilobytes (KB).
Using the binary definition (1 \text{ KB} = 1024 \text{ bytes}):
\text{Size in KB} = \frac{2,359,296}{1024} = 2,304 \text{ KB}

Answer: 2304 KB.

⚠︎ Confusing Bits and Bytes in Calculations
The Error: Students often forget to convert between bits and bytes when the question provides colour depth in bytes or asks for the answer in bits.

Specific Mistake 1: If the colour depth is given as 2 bytes per pixel, students sometimes use '2' directly in the bit calculation. They must multiply by 8 first (2 \times 8 = 16 bits).

Specific Mistake 2: When converting the final answer from Bytes to Kilobytes, some candidates divide by 1000 (decimal) instead of 1024 (binary). Cambridge requires 1024 for storage units.

Correct Approach: Always track your units. If the question asks for bits, leave it in bits. If it asks for KB, ensure you have converted to Bytes first, then divide by 1024.

Using Correct Terminology for Compression
When to use this phrase: When asked to define file compression or state its purpose.

Why examiners accept this: Examiners look for precise definitions. Simply saying 'making files smaller' is often too vague. You must explicitly mention storage space and/or transmission time.

Correct Usage: "Compression reduces the number of bits required to represent data." OR "The purpose of compression is to reduce file size to save storage space and reduce transmission time over networks with limited bandwidth."

Example Answer: "File compression is the process of reducing the size of a file by encoding information using fewer bits. This is needed to save storage space on devices with limited capacity and to reduce the time taken to transmit files over networks with limited bandwidth."

Purpose and Need for Data Compression

Data compression is essential because digital media (images, audio, video) contains a vast amount of data. Without compression, storing and transmitting this data would be inefficient.

The primary needs for compression are:

  1. To save storage space: Hard drives and memory cards have finite capacity. Compression allows more data to be stored in the same physical space.
  2. To reduce transmission time: Data is sent over networks (internet, Wi-Fi). Networks have a limited bandwidth (data transfer rate). Smaller files take less time to upload and download.
  3. To lower costs: Storage hardware and data transfer plans often cost more for larger capacities or higher data volumes. Compression reduces these costs.
Lossless vs. Lossy Compression

There are two main types of compression:

  1. Lossless Compression:

    • Definition: Compresses data without losing any information. The original data can be perfectly reconstructed from the compressed data.
    • How it works: It identifies and removes redundancy (repeated patterns) in the data.
    • Methods:
      • Run-Length Encoding (RLE): Replaces sequences of identical data values with a count and a single value. For example, 'AAAAA' becomes '5A'.
      • Dictionary-based methods (e.g., LZW): Replace repeated occurrences of data patterns with references to a single copy of that pattern.
    • Use cases: Text files, executable programs, and images where detail is critical (e.g., PNG, ZIP).
  2. Lossy Compression:

    • Definition: Compresses data by permanently removing some information. The original data cannot be perfectly reconstructed.
    • How it works: It removes data that is less perceptible to human senses (visual or auditory). This relies on the characteristics of human perception.
    • Methods:
      • For Images: Reduces colour precision or removes high-frequency details that the eye cannot easily see. For example, JPEG compression groups pixels and averages their colours.
      • For Audio: Removes frequencies that are outside the range of human hearing or are masked by louder sounds.
    • Use cases: Streaming media, photography, and music where small quality loss is acceptable for much smaller file sizes (e.g., JPEG, MP3).
⚠︎ Confusing Compression Types with File Formats
The Error: When asked to name a type of compression, students often give an example file format (e.g., 'MP3') instead of the method.

Why this is wrong: MP3 is a file format that uses lossy compression. It is not the type of compression itself.

Correct Understanding:

  • If asked for a type, answer: Lossless or Lossy.
  • If asked for an example of lossless compression, you can say Run-Length Encoding (RLE) or ZIP.
  • If asked for an example of lossy compression, you can say JPEG or MP3.

Always distinguish between the method (how it works) and the format (the file extension).

Explaining How Lossy Compression Works
When to use this phrase: When asked to explain how lossy compression reduces file size.

Why examiners accept this: Examiners require you to link the technical process to human perception. Simply saying 'it deletes data' is insufficient. You must explain what kind of data is deleted.

Correct Usage: "Lossy compression removes data that is less significant to human perception. For example, in images, it may reduce colour depth or remove high-frequency details that the eye cannot detect. In audio, it removes frequencies outside the audible range."

Example Answer: "Explain how lossy compression works for an image file."
"Lossy compression reduces file size by removing data that is less perceptible to the human eye. This includes reducing the precision of colour values and eliminating high-frequency details that do not significantly affect the visual appearance of the image."

Past Paper Style Questions
Q:
State how many bits are in a kibibyte (KiB). [1]
A:
8192
Q:
State the purpose of file compression. [1]
A:
To reduce the size of a file / To save storage space / To reduce transmission time.
Q:
Distinguish between lossless and lossy compression. [2]
A:
Lossless compression allows the original data to be perfectly reconstructed from the compressed data, whereas lossy compression does not allow perfect reconstruction because some data is permanently removed.
Q:
Explain how Run-Length Encoding (RLE) works. [2]
A:
RLE replaces sequences of identical data values with a count and a single value. For example, 'AAAA' is replaced by '4A', reducing the number of bits needed to store the repeated character.
Beta v0.7.8 Free while we're in beta — it transitions to paid post launch. Thank you for supporting us at this stage!