An algorithm is designed to analyze a sequence of temperature sensor readings stored in an array named telemetry. The algorithm's purpose is to find the length of the longest continuous period during which the temperature remained constant (the longest steady-state run).
The pseudocode below contains several missing parts, represented by the labels L1 and L2.
telemetry ← [array of temperature readings]
max_steady ← 0
curr_steady ← L1
index ← 0
WHILE index < LEN(telemetry) - 1
IF telemetry[index] = telemetry[index + 1] THEN
curr_steady ← curr_steady + 1
ELSE
IF curr_steady > max_steady THEN
max_steady ← curr_steady
ENDIF
curr_steady ← L2
ENDIF
index ← index + 1
ENDWHILE
IF curr_steady > max_steady THEN
max_steady ← curr_steady
ENDIF
Identify the correct value that must be assigned to L2 to ensure the algorithm correctly calculates the maximum steady-state run length.
000
111
max_steady\text{max\_steady}max_steady
index\text{index}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.