Full Marks

A-level Computer Science Year 13 · Topic 13

Exchanging data

Exchanging data covers how data is compressed, protected and sent between computers.

We will compare compression methods, symmetric and asymmetric encryption, digital signatures and certificates.

Then we revisit networks, protocols, packet switching, network security, web technologies and how search engines rank pages.

In this topic

  1. 13.1Data compression: lossy and lossless, run-length encoding and dictionary codingFree below · 24 questions
  2. 13.2Encryption: symmetric and asymmetric, digital signatures and certificatesOpen in Full Marks · 31 questions
  3. 13.3Networks: LANs, WANs, topologies, client-server and peer-to-peerOpen in Full Marks · 66 questions
  4. 13.4Network protocols, the TCP/IP stack and DNSOpen in Full Marks · 73 questions
  5. 13.5Packet switching, circuit switching, routers and gatewaysOpen in Full Marks · 28 questions
  6. 13.6Network security: firewalls, proxies and threatsOpen in Full Marks · 73 questions
  7. 13.7Web technologies: HTML, CSS, JavaScript and client-side versus server-side processingOpen in Full Marks · 34 questions
  8. 13.8Search engine indexing and the PageRank algorithmOpen in Full Marks · 26 questions

13.1 · Free notes

Data compression: lossy and lossless, run-length encoding and dictionary coding

Diagram: Data compression: lossy and lossless, run-length encoding and dictionary coding

Key points

In more detail

Practice

Data compression: lossy and lossless, run-length encoding and dictionary coding: 10 questions

Pick an answer to check it, or open the answer for the explanation.

1. Which of the following file formats uses lossless compression?

  1. PNG
  2. MPEG-4 video
  3. JPEG
  4. MP3
Show answer

A: PNG. PNG uses lossless compression, so the image is restored exactly. JPEG, MP3 and MPEG-4 all discard data permanently, which makes them lossy.

2. Using run-length encoding (count then value), what is the encoding of WWWWWBBWWW?

  1. 5W2B1W
  2. W5B2W3
  3. 10W2B
  4. 5W2B3W
Show answer

D: 5W2B3W. There are three runs: five W, two B, then three W, giving 5W2B3W. Separate runs of the same value are not merged.

3. A run-length encoded string is 3X2Y4Z. How many characters does the decompressed data contain?

  1. 24
  2. 9
  3. 6
  4. 12
Show answer

B: 9. Add the counts: 3 + 2 + 4 = 9 characters (XXXYYZZZZ). Multiplying the counts would be wrong.

4. A row of 200 white pixels (1 byte each) is stored as one RLE pair of 2 bytes (count, colour). What is the compression ratio for this row?

  1. 198:1
  2. 200:1
  3. 2:1
  4. 100:1
Show answer

D: 100:1. Ratio = original ÷ compressed = 200 bytes ÷ 2 bytes = 100, written 100:1. The 198 bytes is the saving, not the ratio.

5. Why is RLE a poor choice for compressing a photograph with many slightly varying colours?

  1. RLE needs a dictionary sent with the file
  2. RLE is lossy so quality would drop
  3. There are few long runs of identical values, so output may grow
  4. RLE only works on text files
Show answer

C: There are few long runs of identical values, so output may grow. Photographs have few long runs of identical values, so each pixel becomes its own (1, value) pair and the file can get bigger. RLE is lossless and works on any data.

6. A 600-character text contains the 6-character word SYSTEM 20 times. Each is replaced by a 1-character code. How many characters remain, ignoring the dictionary?

  1. 500
  2. 480
  3. 580
  4. 120
Show answer

A: 500. Each of 20 occurrences shrinks from 6 to 1 character, saving 5 each = 100. So 600 − 100 = 500 characters, before counting the dictionary entry itself.

7. Why is lossy compression unsuitable for a program's executable file?

  1. Executables are too large to compress
  2. Executables are already stored using RLE
  3. Altered bytes would corrupt the program
  4. Lossy methods only work on audio
Show answer

C: Altered bytes would corrupt the program. Lossy compression discards data permanently. Even a few changed bytes in machine code could make the program crash, so executables need lossless compression.

8. What happens to the detail discarded when an image is saved as a JPEG?

  1. It is held in a dictionary for later use
  2. It is restored when the image is opened
  3. It is moved to a separate file
  4. It is permanently lost and cannot be recovered
Show answer

D: It is permanently lost and cannot be recovered. Lossy compression permanently removes data, so the original cannot be rebuilt exactly from the compressed file.

9. A 12 MB file is compressed to 3 MB. What is the percentage reduction in file size?

  1. 25%
  2. 400%
  3. 75%
  4. 9%
Show answer

C: 75%. (12 − 3) ÷ 12 × 100 = 75%. The figure 25% is the compressed size as a fraction of the original, and 4:1 is the ratio.

10. Which statement about dictionary-based compression is correct?

  1. It removes sounds that humans cannot hear
  2. It replaces repeated sequences with shorter codes
  3. It only works on runs of identical characters
  4. It always discards data permanently
Show answer

B: It replaces repeated sequences with shorter codes. Dictionary coding replaces repeated sequences with shorter references to dictionary entries and is lossless. Removing sounds is lossy audio coding, and runs of identical values describe RLE.

Keep going in Full Marks

Full Marks has 24 questions on Data compression: lossy and lossless, run-length encoding and dictionary coding (14 more than here), set out in practice levels. You also get notes and 3D models for all 8 subtopics of Exchanging data, plus games, timed exams and past papers.

On your exam board

All A-level Computer Science Year 13 topics