Skip to topic
    ← Back to course topics

    Data compression — AQA GCSE Computer Science

    Verified courseTeaching note checked against the official specification.

    Data compression reduces file size by encoding information using fewer bits than the original representation, categorized into lossy and lossless techniques. In AQA GCSE Computer Science, understanding algorithms like Run Length Encoding and Huffman coding is vital for evaluating bandwidth usage, transmission speed, and storage efficiency.

    Data compression explained

    Data compression is the process of reducing the number of bits needed to store or transmit a file, so the same information takes up less space.

    Read the full explanation

    A compression method looks for redundancy — repeated or predictable patterns — and records it more economically. For example, a bitmap with large areas of identical colour can be stored by recording the colour once with a count of how many pixels share it, rather than storing every pixel separately. The compressed version must still allow the original data to be recovered, either exactly (lossless) or approximately (lossy). In an MCQ, identify the option that describes reducing file size by encoding data more efficiently, and reject options that merely describe deleting data, increasing resolution or changing file format without reducing the bits stored.

    Read the Data compression study guideFull revision notes for AQA GCSE Computer Science

    Your focus

    1. State that data compression reduces the number of bits needed to store or transmit data.
    2. Identify that compression exploits redundancy such as repeated patterns.
    3. Select the option that correctly describes compression rather than deletion or format change.

    Which command word is this?

    Set out the causes, reasons, or mechanisms clearly. Link your points using connectives like 'because', 'therefore', or 'meaning that', especially when discussing data loss or transmission speeds.

    Data compression exam tips

    Topic Overview

    Data compression is the process of reducing the physical size of a data file by re-encoding its contents using fewer bits than the original representation. In AQA GCSE Computer Science, compression is divided into two fundamental methodologies: lossy compression, which permanently deletes redundant data, and lossless compression, which reduces file size without losing any original information.

    Understanding compression is vital because modern computing relies heavily on transferring and storing vast volumes of digital media over bandwidth-constrained networks. By mastering algorithms like Run Length Encoding (RLE) and Huffman coding, students learn how mathematical representations optimize secondary storage limits, reduce web transmission latency, and maintain software integrity.

    Key Concepts
    • →Lossy compression permanently discards imperceptible or redundant data to achieve significant file size reduction, ideal for audio (MP3), images (JPEG), and streaming video (MP4).
    • →Lossless compression reconstructs the original file byte-for-byte with zero quality loss, essential for program executables, text files, and source code (ZIP, PNG, FLAC).
    • →Run Length Encoding (RLE) compresses data by replacing consecutive repeated data values with a single frequency count and value pair.
    • →Huffman coding builds a binary tree based on character frequencies to assign shorter bit patterns to frequently occurring characters and longer patterns to rarer ones.
    • →Network advantages of compression include reduced transmission times, less bandwidth consumption, and lower network congestion.
    Marking Points
    • Compression reduces the number of bits required to store or transmit data, so file size falls.
    • Compression works by identifying and encoding redundancy such as repeated patterns or predictable values.
    • The compressed data can be decompressed to recover the original information, exactly or approximately.
    • Compression is not the same as deleting data or discarding information the user still needs.
    • A correct MCQ choice describes encoding data more efficiently so fewer bits represent the same content.
    Examiner Tips
    • 💡Read every option and ask which one describes reducing the bits needed to represent the data.
    • 💡Eliminate options that describe deleting data or increasing file size.
    • 💡Link your chosen answer to the idea of redundancy being encoded more efficiently.
    • 💡When explaining the advantages of compression in exam questions, always mention both the reduction in secondary storage space and the reduction in network transmission time.
    • 💡In Huffman coding calculation questions, write down your character frequency counts clearly before multiplying by the bit lengths to ensure you pick up method marks even if an arithmetic error occurs.
    • 💡Read the question carefully regarding ASCII bit lengths; AQA questions frequently specify either 7-bit or 8-bit ASCII, which directly impacts your uncompressed size calculations.
    Common Mistakes
    • Thinking compression means deleting parts of a file permanently; correction: compression re-encodes the same information using fewer bits, and lossless methods recover it exactly.
    • Confusing compression with changing file format; correction: converting a file type does not necessarily reduce the bits stored, whereas compression specifically reduces the number of bits.
    • Assuming compression always loses quality; correction: lossless compression preserves the original data exactly, while only lossy compression discards some detail.
    • Thinking lossy compression is always superior because it achieves smaller file sizes; lossy permanently destroys data, making it unsuitable when exact precision is required.
    • Confusing data compression with data encryption; compression aims to make files smaller for storage/transmission, whereas encryption aims to make data unreadable without a decryption key.
    • Assuming every file can be compressed indefinitely; files with high entropy (randomness) or files that are already compressed may actually increase in size if re-compressed with lossless methods.
    Revision Plan
    1. 1Day 1: Learn the definitions, trade-offs, and file extensions associated with lossy and lossless compression.
    2. 2Day 2: Practice Run Length Encoding (RLE) by encoding and decoding text strings and monochrome 2D pixel grids.
    3. 3Day 3: Learn how to interpret and traverse Huffman trees to derive variable-length binary prefix codes.
    4. 4Day 4: Work through exam-style calculation questions comparing uncompressed ASCII bit counts with compressed Huffman representations.
    5. 5Day 5: Complete timed past paper exam questions focused on scenario-based recommendations (e.g. streaming vs document archival).
    Exam Question Types
    • 📋Scenario-based justification: Choosing lossy or lossless compression for a specific user scenario (e.g. medical imaging vs music streaming) and explaining why.
    • 📋Huffman tree decoding and encoding: Traversing a provided tree from root to leaf to decipher binary strings or generate codes for given letters.
    • 📋Size comparison calculations: Calculating the exact number of bits or bytes saved by applying RLE or Huffman coding compared to standard representations.
    • 📋Definition and trade-off short answers: Defining lossy and lossless compression and outlining the impact on download speeds and visual/auditory quality.
    Command Word Expectations (AQA)
    Explain

    Set out the causes, reasons, or mechanisms clearly. Link your points using connectives like 'because', 'therefore', or 'meaning that', especially when discussing data loss or transmission speeds.

    Calculate

    Arrive at a numerical answer showing all working out. Always include intermediate multiplication steps and state the correct units (bits or bytes).

    State / Give

    Provide a concise, factual answer without detailed explanation, such as identifying a suitable compression type or naming a file format.

    How Students Lose Marks (Examiner Pitfalls)
    Pitfall: Suggesting lossy compression for text files or computer programs to maximise file size reduction.
    ❌ Weak Answer (Loses Marks):Lossy compression should be used for text files because it makes the file as small as possible so it downloads faster.
    Example improved answer:Lossy compression cannot be used on text files or program code because it discards data permanently. Losing characters or instructions would corrupt the text, alter the meaning, or render the program unexecutable. Lossless compression must be used instead so the original file can be reconstructed exactly.
    Examiner Tip: Always link the compression type to the tolerance of data loss: media (audio, video, images) can tolerate lossy compression, while executable code, databases, and text strictly require lossless compression.
    Pitfall: Calculating Huffman coding savings by merely counting tree levels rather than multiplying each character bit length by its frequency.
    ❌ Weak Answer (Loses Marks):The tree has 4 levels, so all characters take 4 bits, which is less than ASCII 8 bits.
    Example improved answer:To calculate the compressed size, multiply each distinct character frequency by the length of its unique variable-length binary path in the Huffman tree, then sum these values together. Compare this total directly against the original size calculated as total characters multiplied by standard ASCII bit length (usually 7 or 8 bits).
    Examiner Tip: Show every multiplication step explicitly in Huffman coding questions: frequency multiplied by bit length for each character, followed by the final summation.
    Step-by-Step Worked Solutions

    Question: A monochrome bitmap image contains a row with the following sequence of pixels: 8 White, 14 Black, 3 Black, and 12 White. Explain how Run Length Encoding (RLE) compresses this sequence and calculate the number of bytes required to store this row if each run is represented by a 1-byte counter followed by a 1-byte colour value (where 0 is Black and 255 is White).

    1. 1.Step 1: Simplify consecutive runs of identical colour. The sequence has 14 Black followed immediately by 3 Black, which combines into a single continuous run of 17 Black pixels.
    2. 2.Step 2: Identify the distinct runs in order: Run 1 = 8 White; Run 2 = 17 Black; Run 3 = 12 White. This results in exactly 3 colour runs.
    3. 3.Step 3: Calculate the storage requirement per run. Each run requires 1 byte for frequency and 1 byte for pixel value: 2 bytes per run.
    4. 4.Step 4: Compute the total bytes: 3 runs multiplied by 2 bytes per run = 6 bytes.
    Final Answer: The combined sequence has 3 runs (8 White, 17 Black, 12 White). At 2 bytes per run (1 count byte + 1 colour byte), the row requires 6 bytes.

    Question: The word 'LEVEL' is encoded using standard 8-bit ASCII. A Huffman tree produces the following variable-length codes: L = '0', E = '10', V = '11'. Calculate the number of bits saved by using this Huffman coding scheme compared to 8-bit ASCII.

    1. 1.Step 1: Calculate original uncompressed size using 8-bit ASCII. 'LEVEL' has 5 characters: 5 characters * 8 bits = 40 bits.
    2. 2.Step 2: Determine character frequencies in 'LEVEL': L appears 2 times, E appears 2 times, V appears 1 time.
    3. 3.Step 3: Calculate the compressed bit length for each character type using the given codes: L (1 bit) * 2 = 2 bits; E (2 bits) * 2 = 4 bits; V (2 bits) * 1 = 2 bits.
    4. 4.Step 4: Sum the compressed bits: 2 + 4 + 2 = 8 bits.
    5. 5.Step 5: Calculate total bits saved: 40 bits (original) - 8 bits (compressed) = 32 bits.
    Final Answer: Standard ASCII requires 40 bits, while the Huffman scheme requires 8 bits, resulting in a total saving of 32 bits.
    Active Recall Memory Test
    What is the defining difference between lossy and lossless data compression?
    Key Fact: Lossy permanently removes data to achieve smaller sizes, while lossless reduces file size without any loss of data, allowing original reconstruction.
    How does Run Length Encoding (RLE) represent repeated sequences of data?
    Key Fact: RLE records consecutive repeated data items as a frequency count followed by the data value (e.g., 'AAAA' becomes '4A').
    In a Huffman coding tree, which characters receive the shortest binary codes?
    Key Fact: The most frequently occurring characters are placed nearest to the root and receive the shortest binary codes.
    Give two practical benefits of compressing video files prior to web transmission.
    Key Fact: Compressing videos reduces transmission time (faster loading/streaming) and consumes less network bandwidth/data allowance.
    Frequently Asked Questions
    Why can you not use lossy compression on text files or software programs?
    Lossy compression permanently discards data that it deems unnecessary or imperceptible to humans. In a text file or program, every character, comma, and instruction is vital; discarding even a single character can introduce spelling errors, alter numerical meaning, or cause code syntax errors that prevent the program from running.
    What is a prefix code in Huffman coding?
    A prefix code is a binary code system where no character code is a prefix (start) of any other character code. In a Huffman tree, all characters reside exclusively at leaf nodes, which ensures that a continuous stream of compressed binary bits can be uniquely and unambiguously decoded from left to right without needing spaces between characters.
    Does data compression always make a file smaller?
    No, lossless compression does not guarantee a smaller file in every scenario. If a file contains completely random data or has already been compressed, applying an algorithm like RLE can actually increase the overall file size because the overhead of storing frequency counters exceeds any repetition savings.
    Why is Huffman coding more efficient than standard ASCII for encoding text?
    Standard ASCII uses a fixed bit length (usually 7 or 8 bits) for every character, regardless of how often it appears. Huffman coding uses variable-length codes, assigning the shortest bit codes to the most frequent letters (like 'E' or 'T') and longer codes to rare letters (like 'Z' or 'Q'), thereby reducing the overall total number of bits required to represent the text.
    How does Run Length Encoding work on colour images?
    RLE works on images by scanning pixels in rows and grouping consecutive pixels of the identical colour together. Instead of storing each pixel colour separately, RLE stores a pair of values: the number of consecutive identical pixels (run length) followed by the colour value (e.g. RGB value or palette index), which dramatically cuts file size across areas with solid background colours.