AQA GCSE Computer Science: Data Representation and Compression
Fundamentals of Data Compression
Definition of Data Compression: The application of algorithms to reduce the total physical size (number of bits) required to store or transmit digital files.
Definition of Decompression: The reciprocal process by which compressed data is reconstructed back into its original or usable format.
Primary Drivers for Compression:
Minimizing physical storage requirements on local disks and remote servers.
Reducing transmission time across computer networks and the internet.
Enabling real-time streaming of rich multimedia data (sound, images, video) across bandwidth-constrained network infrastructures.
The High-Definition (HD) Video Bandwidth Problem:
Display Specifications: A standard High-Definition television (HD TV) image possesses a pixel resolution of .
Pixel Density per Frame: This produces approximately () per frame.
Colour Depth: Operating at a standard depth ( per pixel), each raw uncompressed frame requires:
Frame Rate: Standard broadcast television operates at .
Bandwidth Demand: Transmitting raw, uncompressed video at this fidelity requires:
Network Limitations: Average residential broadband connections in the United Kingdom typically operate under . Streaming uncompressed HD video () across a network connection is physically impossible without aggressive data compression algorithms.
Compression Categories: Lossy vs. Lossless
Lossy Compression:
Mechanism: Permanently identifies and eliminates redundant, imperceptible, or less critical data from the file.
Permanence: Discarded data is permanently lost and cannot be recovered upon decompression.
Primary Usage: Media formats where minor data variations are negligible to human perception, including photography, consumer audio, and video streams.
Inapplicability to Code and Text: Lossy compression cannot be used for computer software, executable code, databases, or text documents. Removing even single characters or instructions corrupts the syntax, causing syntax errors or critical program failure.

Digital Artefacts in Lossy Media:
Definition: Perceptual distortions, imperfections, or errors introduced into digital images, audio, or video as a direct consequence of lossy compression discarding data.
Noise: Visible speckling or fringing commonly appearing along sharp borders between contrasting colours.
Blocking: Distinct square or rectangular pixel grids ("macroblocking") appearing when compression algorithms approximate large clusters of adjacent pixels.

Lossless Compression:
Mechanism: Retains all underlying data without discarding any information. Algorithms detect repeated patterns and encode them compactly without losing original precision.
Reversibility: When uncompressed, the reconstructed file matches the original bit-for-bit with fidelity.
Primary Usage: Executable computer code, textual documentation, sensitive database files, and specialized image formats requiring preservation of sharp edges or transparency (e.g., PNG, TIFF, GIF).
Run Length Encoding (RLE)
Underlying Principles:
A basic form of lossless compression that exploits continuous sequences of identical data elements ("runs").
Instead of recording each individual recurring value, RLE records a frequency/data pair containing the frequency (the number of consecutive identical items) followed by the actual data value.

Worked Example 1: Block Pattern Encoding:
Given a run consisting of consecutive orange pixels followed by consecutive cyan pixels:
Uncompressed recording requires storing all individual colour states.
RLE records the sequence as two frequency/data pairs: , .

Worked Example 2: Single-Row Monochrome Bitstream:
Convention: Let and .
Raw Pixel Stream:
Uncompressed Length: .
Analysis of Runs: Contains a run of four followed by a run of twelve .
RLE Frequency/Data Representation: Recorded as .

Worked Example 3: Two-Dimensional Monochrome Icon Grid:
Grid Dimensions: ( total).
Uncompressed Row Representation (, ):
Row 1:
Row 2:
Row 3:
Row 4:
Row 5:
Contiguous Serialized Bitstream:
Run Sequence Derivation:
First run: four
Second run: one
Third run: four
Fourth run: sixteen continuous (one from row 2 plus fifteen across rows 3, 4, and 5)
Encoded RLE String:
Dictionary-Based Text Compression
Operational Mechanism:
Lossless text compression technique that identifies recurring words, phrases, or character patterns throughout a text document.
Constructs an indexed lookup table (a "dictionary") where each distinct text pattern is assigned a compact numeric binary code (pointer).
The text is then replaced by the sequence of corresponding index codes, followed by the dictionary table.
Index | Binary Code | Dictionary Entry Pattern |
|---|---|---|
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
Worked Case Study: "An eye for an eye, a tooth for a tooth."
Character Count: The phrase contains (including spaces and punctuation).
Uncompressed ASCII Storage: Using an standard ( per character):
Encoded Index Sequence:
Binary Encoded Sequence ( pointers):
Compressed Text Bit Size:
Storage Comparison: The encoded token stream requires only , which represents approximately of the original text payload (exclusive of dictionary overhead storage).
Huffman Coding: Principles and Tree Construction
Core Algorithm Concept:
A variable-length lossless prefix encoding algorithm invented by David Huffman.
Analyzes the frequency of each distinct character within a body of text.
Most frequently used characters are assigned the shortest binary paths near the root node of a binary tree.
Least frequently occurring characters are placed deepest within the binary tree and assigned longer binary bitstrings.
Avoids prefix ambiguity: no assigned character code is ever a prefix of another character code.

Analysis of "SHE SELLS SEA SHELLS":
Frequency Breakdown:
S:E:L:Space:H:A:Total Characters:
Huffman Binary Tree Path Assignments:
Sis encoded asEis encoded asLis encoded asSpaceis encoded asHis encoded asAis encoded asSample Word Encoding:
The word
LEASHis encoded as: Total bits used: .Complete Sentence Encoding:
Encoded sequence for
SHE SELLS SEA SHELLS:Total bit length: .
Comparison with Standard 7-Bit ASCII:
Original sentence contains .
total size:
Huffman encoded size: .
Overall lossless reduction: reduction in file size.

Step-by-Step Tree Construction: "JANE BINNED NINE BAD BANANAS"
Frequency Table Compilation:
Character count verification: Total string length is .
J:S:I:D:B:E:Space:A:N:Verification: .
Step 1: Combine the Lowest Frequency Pair (
JandS)Identify nodes with lowest weights:
J() andS().Form a new bottom-up subtree with root weight , with
JandSas leaf children.Step 2: Combine the Next Lowest Pair (
IandD)Identify nodes with next lowest weights:
I() andD().Note: The existing subtree
[J, S]also has weight . One could pairIorDwith that subtree, but pairingIandDcreates a distinct subtree of weight .Step 3: Merge Character
Bwith Subtree[J, S]Lowest available weights are subtree
[J, S](weight ) and charactersB(weight ) orE(weight ).Pair
B() with subtree[J, S]() under a new parent node of weight .Step 4: Merge Character
Ewith Subtree[I, D]Character
E() is combined with subtree[I, D]().Create a parent node of weight .
Step 5: Combine
Spaceand CharacterAThe remaining single leaf nodes with lowest weights are
Space() andA().Combine into an independent subtree of weight .
Step 6: Merge Subtrees
[J, S, B]and[I, D, E]Subtree
[J, S, B]has weight . Subtree[I, D, E]has weight . CharacterNhas weight .Joining subtree
[J, S, B]() with subtree[I, D, E]() produces a balanced branch of combined weight .Step 7: Merge Character
Nand Subtree[Space, A]Character
N() is combined with subtree[Space, A]() to form a branch of weight .Step 8: Construct the Final Root Node
Merge branch and branch under the primary root node: .
The root node value () matches the total character count of the original message.
Step 9: Branch Weight Assignment
Traverse the tree from top to bottom: assign binary digit
0to every left-hand branch and binary digit1to every right-hand branch.

Huffman Tree Structural Properties:
Different choices when breaking ties between identical frequencies produce alternate tree shapes.
Regardless of which valid pairing order is chosen, the resulting Huffman trees remain optimal and prefix-free.
Practical Network Transmission, Streaming, and Buffering
System Benefits of Data Compression:
Packet Reduction: Smaller overall file payloads decompose into fewer data packets, leading directly to reduced transmission times across wide area networks.
Network Congestion Relief: Lower packet counts minimize traffic congestion across network routers and backbones.
Faster Downloads: Drastically cuts latency and transfer durations for video, web graphics, and audio payloads (including VoIP telecommunication protocols).
Bandwidth Allowance Efficiency: Maximizes the utility of metered mobile or broadband monthly data caps.
Storage Optimization: Frees storage space on web servers and local solid-state/magnetic disk drives.
Music Track Download Case Study: "Dancing Queen" by ABBA:
Track Length: .
Compressed MP3 Stream Calculation:
MP3 streaming bitrate: .
Total bits transmitted: .
File size in megabytes: .
Uncompressed CD Audio Stream Calculation:
Standard CD audio bitrate: .
Total bits transmitted: .
File size in megabytes: .
Performance Gain: The MP3 compressed file downloads faster and saves approximately of bandwidth compared to CD audio.
Video Streaming Mechanics and Buffering:
Real-Time Playback Requirement: Streaming multimedia functions only when data reaches the client device at or faster than the rate at which it is decoded and rendered.
Root Cause of Buffering: Buffering delays occur whenever downstream network download throughput drops below the designated playback bitrate of the media stream.
Mitigation Strategies:
Pre-buffering: Prior to initiating playback, client applications cache an initial reservoir of video frames to absorb transient jitter, latency spikes, or temporary bandwidth drops.
Adaptive Bitrate Streaming: Content Delivery Networks (CDNs) continuously monitor client connection stability; if congestion or slow throughput is detected, the server dynamically switches downstream delivery to an alternative, lower-bitrate compressed video stream.
Standard File Formats and Compression Schemes

Comparative Reference Table:
File Format | Compression Type | Primary File Usage and Characteristics |
|---|---|---|
JPEG / JPG | Lossy | High-colour digital photography and web imagery; produces small file sizes at the cost of slight loss in fine edge detail. |
PNG | Lossless | Graphic design, screenshots, and web illustrations; supports full alpha-channel transparency with exact pixel reproduction. |
ZIP | Lossless | General-purpose archive container for documents, source code, and multi-file archives; fully preserves original file contents. |
GIF | Lossless | Simple animations, icons, and low-colour web diagrams; limited to an indexed colour palette of up to . |
MP4 | Lossy | Standard container for digital video and synchronized audio streams across streaming web platforms and mobile media. |
MP3 | Lossy | Standard digital music encoding; exploits perceptual audio coding to eliminate acoustic frequencies imperceptible to human hearing. |
FLAC / ALAC | Lossless | Audiophile and studio audio mastering; provides bit-perfect audio reproduction (Free Lossless Audio Codec / Apple Lossless Audio Codec). |