Skip to content

Course home

Data compression

Data compression

EasyMedium
123456789101112131415161718192021222324
Question 12

Select one option to show what code should be written at point P5 of the algorithm in Figure 1 to correctly decompress a run-length encoded string consisting of single-digit counts followed by their corresponding characters (such as "3A2B" representing "AAABB").

Figure 1

compressed ← USERINPUT
decompressed ← ""
i ← 0
WHILE i < LEN(compressed)
    count ← TO_INTEGER(compressed[i])
    char ← compressed[i + 1]
    j ← 0
    WHILE j < count
        decompressed ← decompressed + char
        j ← j + 1
    ENDWHILE
    P5
ENDWHILE
OUTPUT decompressed
A

i←i+1i \leftarrow i + 1i←i+1

B

i←i+2i \leftarrow i + 2i←i+2

C

i←i+counti \leftarrow i + \text{count}i←i+count

D

i←i+ji \leftarrow i + ji←i+j

Markscheme

Data compression Questions

  1. GCSE
  2. /Computer Science
  3. /Data compression

37 exam-style questions on AQA GCSE Computer Science Data compression. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank