Why is data compressed, and how do lossy and lossless compression, including run-length encoding, work?
The need for compression, the difference between lossy and lossless compression, and how run-length encoding compresses data.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on compression, covering why data is compressed, the difference between lossy and lossless compression and when each is used, and how run-length encoding (RLE) compresses repeated data with a worked example.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this topic is asking
WJEC wants you to know why data is compressed, the difference between lossy and lossless compression and when each is appropriate, and how run-length encoding works. This is part of the Data representation and data types content in Unit 1 of WJEC GCSE Computer Science (3500).
Why compress data
Lossy compression
Lossless compression
Run-length encoding
Choosing a method
Use lossy compression when smaller files matter more than perfect fidelity and a slight quality drop is acceptable (streaming media). Use lossless compression when the data must be recovered exactly (documents, code, archives). RLE is only worth using when the data has many repeated runs.
Try this
Q1. State one reason why files are compressed before being sent over the internet. [1 mark]
- Cue. Smaller files use less bandwidth and transmit faster.
Q2. Compress the sequence AAAABBAAAA using run-length encoding. [2 marks]
- Cue. (or pairs ).
Exam-style practice questions
Practice questions written in the style of WJEC exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
WJEC-style Unit 14 marksExplain the difference between lossy and lossless compression, giving one example of when each would be used.Show worked answer →
A Unit 1 compare question. Lossy compression makes a file smaller by permanently removing some data, usually detail that people are less likely to notice, so the original cannot be perfectly recovered (1 mark); it is used for things like streaming music or photos where a small loss of quality is acceptable in return for much smaller files (1 mark). Lossless compression makes a file smaller without losing any data, so the original can be reconstructed exactly (1 mark); it is used where every bit matters, such as compressing a text document, a spreadsheet or program code (1 mark). Markers reward the permanent loss versus exact recovery distinction and a sensible example of each. A common error is to say lossless makes files smaller by deleting data, which describes lossy.
WJEC-style Unit 13 marksA row of pixels is stored as WWWWWBBBBBBWWWW. Show how run-length encoding would compress this row and state why this method saves space here.Show worked answer →
A Unit 1 run-length encoding question. Run-length encoding records each run as the value and the number of times it repeats. The row is five W, then six B, then four W, so it compresses to (or pairs such as ) (2 marks for the correct encoding). It saves space because the data contains long runs of identical values, so storing the value once with a count is shorter than listing every value (1 mark). Markers reward the value-and-count pairs and the reason about repeated runs. A common error is to record each character separately, which does not compress, or to lose the order of the runs.
Related dot points
- Representing bitmap images as pixels, the meaning of resolution and colour depth, calculating the file size of an image, and the role of metadata.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on representing images, covering bitmap images and pixels, resolution, colour depth and the number of colours, calculating image file size from dimensions and colour depth, and the role of metadata.
- Representing sound in binary by sampling an analogue wave, the meaning of sample rate and sample resolution (bit depth), and how they affect sound quality and file size.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on representing sound, covering analogue to digital conversion by sampling, sample rate and sample resolution (bit depth), how each affects sound quality and file size, and calculating the file size of a sound recording.
- The binary and denary number systems, why computers store data in binary, the units of data capacity, and converting whole numbers between binary and denary.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on binary and denary numbers, covering why computers use binary, bits bytes and the units of data capacity, place value in base 2, and converting whole numbers between binary and denary in both directions.
- The purpose of protocols, common protocols (TCP/IP, HTTP and HTTPS, FTP, SMTP), and why network communication is organised into layers.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on protocols and layers, covering what a protocol is and why protocols are needed, the purpose of common protocols such as TCP/IP, HTTP and HTTPS, FTP and SMTP, and why network communication is split into layers.
- The need for secondary storage, the characteristics of magnetic, optical and solid-state storage, and calculating storage requirements and capacity.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on secondary storage, covering why secondary storage is needed, the characteristics, advantages and disadvantages of magnetic, optical and solid-state storage, and calculating how many files of a given size fit in a given storage capacity.