Short on time? This page is the recap. For explanations and worked examples, use the full study guide.
Recap
- Data compression reduces the number of bits needed to store or transmit data.
- Fewer bits does not necessarily mean less information.
- The size saved depends on the redundancy in the data and the algorithm.
- Lossless: usually reduces bits and guarantees complete reconstruction of the original.
- Lossy: can reduce bits significantly, but allows reconstruction of only an approximation.
- Lossy usually reduces size more than lossless.
- Choose lossless when quality or exact reconstruction matters most; choose lossy when minimising size or transmission time matters most.
- Run-length encoding (lossless): store a value and the length of its run.
Key relationships
| Idea | How to work it out |
|---|---|
| Percentage saved | (original size - compressed size) ÷ original size × 100 |
| Size after run-length coding | Number of runs × size of one (count, value) pair |
| Does a method suit the data? | Many repeats: good saving. Few repeats: little or negative saving |
| Lossless or lossy? | Can the exact original be rebuilt? Yes: lossless. Only an approximation: lossy |
| Which to choose? | State the priority (quality or size), then match, then name the trade-off |
Assumptions and conventions
- In size calculations, state the bits per character or pixel you assume (for example 8 bits).
- A “run” is a block of identical values that appear next to each other.
- No specific named algorithm is required.
Mistakes to avoid
- Claiming all compression loses information.
- Choosing lossy for text or code where a single change could corrupt meaning.
- Choosing lossless when the scenario’s priority is small size and speed.
- Forgetting that run-length coding can make data longer if there are few repeats.
- Computing the percentage saved against the compressed size instead of the original.
- Giving a choice without naming the trade-off.
Two quick worked examples
1. WWWWWBBWWWWWWWW has runs of 5 W, 2 B and 8 W, giving 5W2B8W: 15 characters become 6, a saving of 9 ÷ 15 = 60%. Decoding gives back exactly the original, so the scheme is lossless.
2. A picture with 256 shades uses 8 bits per pixel; reducing it to 16 shades uses 4 bits per pixel, halving the size. The original shading cannot be recovered afterwards, so this is lossy.
A revision routine
Write the definitions of lossless and lossy from memory, with one situation where each is the better choice and the reason. Then run-length encode two strings of your own, one with long runs and one with none, and compute the percentage saved or lost for each. Seeing a method fail on the second string fixes the idea that savings depend on redundancy.
Quick self-check
- Encode
AAAABBBCCby run-length. (4A3B2C) - Which type lets you rebuild the exact original? (Lossless.)
- A 40 MB video becomes 10 MB. What percentage is saved? ((40 - 10) ÷ 40 = 75%)
Next: practice questions.