Computer ScienceExam code: 0984

Data Storage and Compression

Data Representation

This comparison comes up regularly in exam questions worth 3 to 4 marks.

FeatureLosslessLossy
Is any data lost?NoYes (permanently)
Can the original be reconstructed?Yes, perfectlyNo
Typical size reductionModest (1.5× to 4×)Large (10× or more)
Effect on qualityNone; quality identical to the originalQuality is reduced
Best forText documents, source code, archives, anywhere every bit mattersPhotos, music, video, anywhere small size matters and minor quality loss is acceptable
ExamplesPNG, FLAC, ZIP, GIF, RLE, PDF textJPEG, MP3, MPEG/H.264, AAC

Common exam question

Explaining why lossless is chosen instead of lossy

Question: Explain why someone would compress a file with lossless rather than lossy compression, or why lossy compression is not suitable for that file (3 marks).

Asked in 2 of the 17 papers, both for 3 marks, and both answers are built from the same chain of points. Lossy compression permanently removes data; that data could be important, so for a text document the file would be damaged or corrupted, and for a sound recording or an image the quality would be reduced. Lossless compression removes nothing permanently, so the original can be restored, kept at its highest quality or edited later.

Tie each point to the file in the question: a report with text and pictures, a recording the musician still wants to edit. "No data is lost" is one of the three marks, not all of them, so develop it into what lossy would do to this particular file.

Choosing which to use

  • If the file is a text document or spreadsheet, choose lossless: a single missing word changes the meaning.
  • If the file is source code or a database backup, choose lossless: a single missing bit can crash the program.
  • If the file is a photograph for a website, choose lossy: a 10× smaller image that looks almost identical is a much better user experience.
  • If the file is a music track to stream over a mobile network, choose lossy: most users cannot hear the difference between a 320 kbps MP3 and the studio master, and the smaller size saves bandwidth.

Build on this topic