Learning Objectives
  • Explain the purpose and need for data compression.
  • Describe the effects of smaller files on storage, bandwidth and transmission time.
  • Distinguish between lossy and lossless compression.
  • Choose a suitable compression type for a given file and purpose.
  • Explain how run-length encoding reduces repeated data and when it may be ineffective.
Key Terms
Compression
Reducing the number of bits needed to store or transmit a file.
Decompression
Reconstructing usable data from a compressed representation.
Lossless compression
Compression that allows the original data to be reconstructed exactly.
Lossy compression
Compression that permanently removes some data.
Run-length encoding
A lossless method that replaces a run of repeated values with the value and a count.
Redundancy
Repeated or predictable data that can be represented more efficiently.
Compression ratio
A comparison between original and compressed sizes; use only when information is provided.
Summary diagram for 1.12 Data Compression Lossy Lossless And RLE
Summary Of The Main Ideas In This Lesson
Why Files Are Compressed

Compression reduces file size. A smaller file requires less secondary storage and can allow more files to fit on the same device. It also contains fewer bits to transmit, so it can use less bandwidth and take less time to upload or download under the same network conditions.

Compression is useful for backups, websites, streaming, email attachments and data transfer. The benefit must be balanced against processing time, compatibility and, for lossy methods, reduced quality.

Compression does not automatically make the content higher quality or more secure. Its main purpose in this syllabus is to reduce the number of bits.

Lossless Compression

Lossless compression represents the data more efficiently without permanently discarding information. After decompression, every bit of the original data can be reconstructed exactly.

Exact reconstruction is necessary for program files, source code, executable instructions, text where every character matters and database records where a changed value could alter meaning. Some images can also be stored losslessly when exact pixels are required.

Lossless compression often exploits repetition or other redundancy. It may achieve less size reduction than a lossy method because it must retain enough information to rebuild the original exactly.

Run-Length Encoding

Run-length encoding is a lossless method suited to data containing long sequences of the same value. Instead of storing every repeated item, the compressed form stores the value and the number of repetitions.

For example, a row of twelve white pixels may be represented conceptually as white x 12. Decompression repeats the stored value the stated number of times, recreating the original run exactly.

RLE is effective for simple images with large areas of one colour and other data containing long runs. It may be ineffective or even larger than the original when values change frequently, because every short run needs both a value and a count.

Lossy Compression

Lossy compression permanently removes selected information. Decompression produces an approximation rather than an exact copy. The method is suitable when some loss is acceptable and a much smaller file is valuable.

For images, lossy compression may remove fine detail or reduce effective colour information. For sound, it may remove or simplify audio detail. The syllabus examples also include reducing image resolution or colour depth and reducing sound sample rate or sample resolution.

Lossy compression is commonly appropriate for photographs, music and video intended for viewing or listening. It is not suitable for executable programs, source code or records that must be reproduced exactly.

Choosing The Correct Compression Type

The best choice depends on purpose. Ask whether exact reconstruction is essential. If any changed bit could make the file incorrect or unusable, choose lossless compression. If the data is perceptual media and a controlled quality reduction is acceptable, lossy compression may provide greater size reduction.

A complete examination explanation links the file type and purpose to the consequence. For example, a program file needs lossless compression because every instruction must be recovered exactly; a website photograph may use lossy compression because a small reduction in visual detail is acceptable and faster download is useful.

Do not state that one method is always better. Lossless protects exact data; lossy often provides smaller files. The suitability depends on the scenario.

Compression And Transmission

When a compressed file contains fewer bits, it normally needs less bandwidth for a given transfer time or less time for a given bandwidth. This can reduce network congestion and make streaming practical.

Compression and decompression require processing, but unless a question focuses on that trade-off, the central syllabus impacts are reduced storage space, reduced bandwidth requirement and shorter transmission time.

Lossless And Lossy Compression
Feature Lossless Lossy
Original recovered exactly Yes No
Data permanently removed No Yes
Typical suitability Programs, text, records, exact images Photographs, sound and video where some loss is acceptable
Quality after decompression Identical to original May contain reduced detail or artefacts
Possible size reduction Often more limited Often greater
Compression Benefits
Area Effect Of A Smaller File
Storage Less space is required; more files can be stored.
Bandwidth Fewer bits need to pass through the network.
Transmission time Upload and download can complete more quickly.
Backups and transfer Large collections are easier to copy or archive.
When RLE Works Well
Data Pattern Likely Effectiveness
Long repeated runs High; value and count replace many repeated items.
Large single-colour image areas Often high.
Rapidly changing values Low; many short runs need extra counts.
Random-looking data Usually low.
Worked Examples
Simple RLE

Question: Represent AAAAABBBCCCCCCCC using conceptual RLE pairs.

  1. Count the run of A: 5.
  2. Count the run of B: 3.
  3. Count the run of C: 8.

Answer: (A,5), (B,3), (C,8).

RLE Suitability

Question: Which row is likely to compress better with RLE: WWWWWWWWWBBB or WBRGWBRGWBRG?

  1. The first row contains two long runs.
  2. The second changes value almost every position.

Answer: The first row is more suitable for RLE.

Choosing Lossless

Question: Choose a compression type for a spreadsheet containing examination marks.

  1. Every value must be restored exactly.
  2. A changed digit would alter a result.

Answer: Lossless compression.

Choosing Lossy

Question: Choose a compression type for a large background photograph on a website.

  1. A small reduction in detail may not be noticeable.
  2. A smaller download improves page loading.

Answer: Lossy compression may be suitable.

Storage Saving

Question: A file is reduced from 80 MiB to 28 MiB. How much storage is saved?

  1. 80 – 28 = 52.

Answer: 52 MiB is saved.

Examination Guidance
  • Define compression as reducing the number of bits, not merely putting files into a folder.
  • For a benefit, state a measurable consequence such as less storage, less bandwidth or shorter transfer time.
  • Use the phrase exact reconstruction when explaining lossless compression.
  • When recommending a method, connect the choice to the file purpose.
  • For RLE, explain value plus run length and mention that long repeated runs are needed.
Common Mistakes
  • Saying lossless means no file-size reduction.
  • Saying lossy data returns after decompression.
  • Claiming RLE is effective for every file.
  • Choosing lossy compression for program instructions or numerical records.
  • Confusing compression with encryption; compression reduces size, while encryption protects confidentiality.
Knowledge Check

1. Why can compression reduce transmission time?

Answer: Fewer bits need to be sent.

2. Why is lossless compression suitable for source code?

Answer: Every character and instruction must be reconstructed exactly.

3. Give one way lossy compression can reduce an image file.

Answer: Reduce resolution, reduce colour depth or permanently remove fine visual detail.

4. When can RLE increase file size?

Answer: When the data changes frequently and many short runs require both a value and a count.

5. What is the main difference between lossy and lossless compression?

Answer: Lossy permanently removes data; lossless allows exact reconstruction.