A weather station program uses an algorithm to find the location with the lowest recorded rainfall.
State what should be written in place of the labels L1, L2, and L3 in the algorithm below to successfully identify and output the station with the lowest rainfall.
SUBROUTINE findMinRainfall(searchType, numSensors)
sensorData ← [['140', '35', '210', '12', '88'],
['North-Peak', 'East-Valley', 'West-Coast', 'South-Ridge', 'Central-Plains']]
idx ← 0
minRain ← 9999
IF searchType = 'MINIMUM' THEN
FOR k ← 0 TO numSensors - 1
rain ← STRING_TO_INT(sensorData[L1][k])
IF rain < minRain THEN
minRain ← rain
idx ← L2
ENDIF
ENDFOR
ELSE
OUTPUT 'operation not supported'
ENDIF
IF minRain ≠ 9999 THEN
OUTPUT 'Lowest rainfall at ', sensorData[1][idx], ' is ', sensorData[0][idx], 'mm'
ENDIF
ENDSUBROUTINE
OUTPUT 'Enter command (MINIMUM or MAXIMUM): '
userQuery ← USERINPUT
findMinRainfall(L3, 5)
L1
L2
L3
131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.