A-level Computer Science revision · Exchanging data

Compression

The idea

Lossy compression permanently removes data that humans are unlikely to notice (as in JPEG or MP3), giving smaller files. Lossless compression keeps all data so the original can be rebuilt exactly. Run-length encoding stores a value and how many times it repeats. Dictionary coding replaces repeated patterns with short references.

  1. Lossy for images, audio, video where small losses are acceptable.
  2. Lossless for text and program files.
  3. RLE works best with long runs of repeated data.

Watch out Program code and text must use lossless compression, or the file would be corrupted.

See it worked

Worked example

Run-length encode AAAABBBCC.

  1. Count each run.
  2. A×4, B×3, C×2.
  3. 4A 3B 2C.

Answer 4A3B2C

Your turn

Question 12 marks

A run of 20 identical pixels is stored by run-length encoding as one count and one colour value. How many values are stored?

Question 21 mark

Which file must be compressed losslessly?

Choose one
Question 31 mark

Which compression method replaces repeated words or patterns with references?

Choose one

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms