📄 Paper 1 · 1.1 Data Representation
1.1.7 Data Compression and Encryption
Cambridge 9618 · International A Level Computer Science · ~14 min read
Notes
Video
Slides
Quiz
Worksheet

Data Compression

Data compression is the process of encoding data using fewer bits than the original representation, reducing file size. There are two types:

Lossless Compression

Lossless compression reduces file size without losing any data. The original file can be perfectly reconstructed from the compressed version.

  • How it works: Finds and removes redundancy — e.g. replacing repeated patterns with shorter codes.
  • Techniques: Run-Length Encoding (RLE), Huffman encoding, LZW algorithm (used in ZIP, PNG, GIF)
  • Used for: Text files, executable programs, spreadsheets, PNG images — any file where every bit must be preserved.

Run-Length Encoding (RLE)

RLE replaces consecutive repeated values with a count and the value:

Original: AAABBBBBCCDDDDDD → RLE: 3A5B2C6D

RLE works well for images with large areas of the same colour (e.g. simple graphics), but poorly for complex photographic images.

Huffman Encoding

Huffman encoding assigns shorter binary codes to more frequently occurring characters and longer codes to rare characters. This reduces the average number of bits per character without losing data.

Lossy Compression

Lossy compression achieves greater compression by permanently discarding some data — data considered least important or least perceptible to humans. The original file cannot be perfectly reconstructed.

  • Techniques: Reducing colour depth, reducing resolution, discarding frequencies beyond human perception (MP3)
  • Used for: Images (JPEG), audio (MP3, AAC), video (MP4) — where small quality loss is acceptable
  • Trade-off: Smaller file size, but quality degrades. Repeated compression worsens quality.
PropertyLosslessLossy
Data lost?No — original perfectly recoverableYes — some data permanently discarded
Compression ratioModerateHigher (better compression)
Use casesText, programs, PNG, ZIPJPEG, MP3, MP4, AAC
Suitable for repeated compression?YesNo — quality degrades each time

Encryption

Encryption is the process of transforming data (plaintext) into an unreadable form (ciphertext) using an encryption key and algorithm. Only an authorised recipient with the correct decryption key can read the original data.

Key Terms

  • Plaintext: The original, readable data before encryption
  • Ciphertext: The encrypted, unreadable output
  • Encryption key: A piece of data (number) used by the algorithm to encrypt/decrypt
  • Algorithm: The mathematical process used to transform plaintext to ciphertext

Symmetric Encryption

The same key is used for both encryption and decryption. The key must be shared securely between sender and recipient.

  • Example: AES (Advanced Encryption Standard)
  • Advantage: Fast, efficient for large data
  • Disadvantage: Key distribution problem — the key must be sent securely

Asymmetric Encryption (Public Key Cryptography)

Uses a public key (for encryption, shared with everyone) and a private key (for decryption, kept secret). Data encrypted with the public key can only be decrypted with the corresponding private key.

  • Example: RSA
  • Advantage: No key distribution problem — public key can be shared openly
  • Disadvantage: Slower than symmetric encryption

Why Encryption Matters

  • Protects data in transit (e.g. HTTPS, email)
  • Protects stored data (e.g. database encryption)
  • Ensures only authorised parties can read sensitive information
Exam tip: Cambridge questions distinguish carefully between lossless (original recoverable, e.g. RLE, Huffman) and lossy (data lost, e.g. JPEG, MP3). For encryption: know the difference between plaintext/ciphertext, symmetric/asymmetric, and the advantage of asymmetric (no key sharing problem). Be able to give specific examples of when each is appropriate.
⚠️ Common Mistakes
  • Confusing lossless with lossy — lossless means NO data is lost
  • Saying RLE works well for photographs — it does not; it works for simple images with repeated colours
  • Confusing encryption (making data unreadable) with compression (reducing file size)
  • Saying symmetric encryption uses two keys — it uses one shared key
  • Not knowing that lossy compression degrades quality on repeated use
✅ Notes completed!
Video coming soon
Click slide or press arrow keys to navigate

Worksheet — 1.1.7 Data Compression and Encryption

8 questions · instantly marked · Cambridge 9618 standard

Q1State the difference between lossless and lossy compression.[2]
✅ Mark scheme
Mark scheme
Lossless: the original file can be perfectly reconstructed — no data is permanently lost [1]; Lossy: some data is permanently discarded to achieve greater compression — the original cannot be perfectly reconstructed [1].
Q2Explain how Run-Length Encoding (RLE) compresses data and give an example.[3]
✅ Mark scheme
Mark scheme
RLE replaces consecutive repeated values with a count and the value [1]; this removes redundancy by encoding runs of the same value compactly [1]; Example: AAAABBBBB → 4A5B (or equivalent) [1].
Q3Explain why lossy compression is more suitable for storing a music file than a text document.[3]
✅ Mark scheme
Mark scheme
A music file can tolerate small quality losses that are imperceptible to human hearing [1]; lossy compression (e.g. MP3) achieves greater compression ratios allowing more efficient storage [1]; a text document must preserve every character exactly — any data loss would corrupt the text, making lossless compression essential for text [1].
Q4Define the terms (a) plaintext and (b) ciphertext in the context of encryption.[2]
✅ Mark scheme
Mark scheme
(a) Plaintext: the original, unencrypted readable data [1]; (b) Ciphertext: the encrypted/scrambled output that cannot be read without the decryption key [1].
Q5State two differences between symmetric and asymmetric encryption.[4]
✅ Mark scheme
Mark scheme
Any two differences (2 marks each): Symmetric uses one shared key for both encryption and decryption; asymmetric uses a pair of keys — public and private [2]; Symmetric requires the key to be securely shared between parties; asymmetric avoids the key distribution problem because the public key can be shared openly [2]; Symmetric is faster/more efficient; asymmetric is slower [2].
Q6Explain what is meant by the 'key distribution problem' in symmetric encryption and how asymmetric encryption solves it.[3]
✅ Mark scheme
Mark scheme
Symmetric encryption requires sender and receiver to share the same secret key [1]; this key must be transmitted securely — but any interception of the key allows an attacker to decrypt all messages [1]; asymmetric encryption solves this: the public key can be shared openly without risk — only the private key (kept secret) can decrypt messages encrypted with the public key [1].
Q7Give one situation where lossless compression is essential and one where lossy compression is acceptable. Justify each choice.[4]
✅ Mark scheme
Mark scheme
Lossless essential: e.g. executable programs / text files / medical images — because every bit must be exactly preserved [1+1]; Lossy acceptable: e.g. music streaming / photographs on social media — because small imperceptible quality losses are acceptable and the higher compression saves bandwidth/storage [1+1].
Q8Explain one advantage of Huffman encoding over a fixed-length encoding scheme for compressing text data.[2]
✅ Mark scheme
Mark scheme
Huffman assigns shorter codes to more frequent characters [1]; this reduces the average number of bits per character, producing a smaller file than fixed-length encoding for typical text data [1].
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 10
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — 1.1.7 Compression & Encryption

10 questions · 10 marks · 10 minutes

← 1.1.6 Sound Representation
7 of 82 · Cambridge 9618
1.2.1 Communication Methods →