A telemetry unit on an atmospheric weather balloon compresses sensor data using Run-Length Encoding (RLE). To reconstruct the original stream of sensor codes, a scientist writes a decoding algorithm. The algorithm takes two parallel arrays of size N N\,N as input: counts (storing the consecutive occurrence counts of each code) and symbols (storing the corresponding sensor codes).
The pseudocode for this decompression algorithm is shown below.
decoded_string ← ""
outer_index ← 0
WHILE outer_index < N
inner_index ← 0
WHILE inner_index < counts[outer_index]
decoded_string ← decoded_string + symbols[outer_index]
L1
ENDWHILE
L2
ENDWHILE
OUTPUT decoded_string
Choose the statement that must be written at line L1 to ensure that each character run is expanded to its correct length and that the algorithm executes without an infinite loop.
outer_index←outer_index+1\text{outer\_index} \leftarrow \text{outer\_index} + 1outer_index←outer_index+1
inner_index←inner_index+1\text{inner\_index} \leftarrow \text{inner\_index} + 1inner_index←inner_index+1
inner_index←counts[outer_index]\text{inner\_index} \leftarrow \text{counts}[\text{outer\_index}]inner_index←counts[outer_index]
inner_index←inner_index+counts[outer_index]\text{inner\_index} \leftarrow \text{inner\_index} + \text{counts}[\text{outer\_index}]inner_index←inner_index+counts[outer_index]
208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.