Use fewer bits to represent the data
Compression reduces the number of bits required to store or transmit a representation. Smaller files need less storage and, at the same transfer rate, less time to send. Encoding and decoding can require processing.
Lossless compression allows the exact original data to be reconstructed. Lossy compression permanently removes some information, often information people are less likely to notice. Decompressing a lossy file does not restore what was discarded.
| Need | Suitable approach | Reason |
|---|---|---|
| Program source or important text | Lossless | Every original character must survive |
| Small music download | Lossy may be suitable | Some sound detail may be sacrificed for a smaller file |
| Image needed for exact scientific measurements | Lossless | Original pixel values must be preserved |
AQA focus
AQA: run-length encoding stores a value and its run length
Run-length encoding (RLE) replaces consecutive repeats with a count and the repeated value. Follow the supplied format: in this example the count comes first. A new run starts when the value changes, even if the earlier value appears again later.
Encode AAAABBBCCDAA
- Four A characters form the first run: 4A.
- Then three B, two C, one D and two A: 3B 2C 1D 2A.
- Combined representation: 4A3B2C1D2A.
- Decoding the counts restores AAAABBBCCDAA exactly.
The two A characters at the end cannot be merged with the first run: order matters.
AQA focus
AQA: connect symbol frequencies to Huffman tree paths
Huffman coding gives variable-length bit codes to symbols. Frequently occurring symbols can receive shorter codes. One way to understand the tree is to repeatedly combine its two lowest-frequency nodes. If frequencies tie, more than one valid tree can exist; always use the tree supplied by the question.
Label the two branches from each node 0 and 1. A symbol's code is the complete route from the root to its leaf. No symbol's code is the beginning of another symbol's code, so the bit stream can be decoded without separators.
Frequencies A:5, B:2, C:1, D:1
- Combine C:1 and D:1 to make node CD:2.
- Combine B:2 and CD:2 to make node BCD:4.
- Combine BCD:4 and A:5 to make the root:9.
- One valid labelled tree gives A=1, B=00, C=010 and D=011.
The more frequent A uses one bit; the less frequent C and D use three each.
OCR focus
OCR: justify lossy or lossless for the user's needs
OCR J277 requires the need for compression and the characteristics and effects of lossy and lossless methods; it does not require constructing a Huffman tree or executing RLE. Focus your answer on retained information, suitability, size and the consequence for this user.
Send a photograph and an executable program
- The photograph may use lossy compression if some loss of visible detail is acceptable.
- The executable must preserve every original bit, so use a lossless method.
- Both may transfer faster if compressed size is smaller; their tolerance for lost information differs.
‘Lossy is always better because it is smaller’ ignores what the file is for.
Continue with your exam board
The course combines lesson videos, interactive activities, topic questions and original exam mocks. Sign in to use the learning tools and save your progress; your account’s course access applies.
Independent learning resources. Not endorsed by AQA or OCR. These public introductions complement the full course and the official specification.