Computer Science · May / June 2024 · Paper 22 · Question 7
0478
As printed in the paper
The question as text
An algorithm has been written in pseudocode to find and display the maximum and minimum values in an array of 1000 positive numbers. The array List[] starts at index 1 01 Max List[1] 02 Min List[1] 03 FOR Counter 2 TO 1000 04 IF List[Counter] < Max 05 THEN 06 Max List[Counter] 07 ENDIF 08IFList[Count]Min 09 THEN 10 Min List[Counter] 11 ENDWHILE 12 NEXT Counter 13 OUTPUT "Maximum value is ", Max 14 OUTPUT "Minimum value is ", Min
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
7(a)[3]
01//02//06//10
04(07) and/or 08
03(12)
7(b)[3]
One mark for each error identified and corrected
Line 04 < should be >
Line 08 Count should be Counter
Line 11 ENDWHILE should be ENDIF
01 Max ← List[1]
02 Min ← List[1]
03 FOR Counter ← 2 TO 1000
04 IF List[Counter] > Max
05 THEN
06 Max ← List[Counter]
07 ENDIF
08 IF List[Counter] < Min
09 THEN
10 Min ← List[Counter]
11 ENDIF
12 NEXT Counter
13 OUTPUT "Maximum value is ", Max
14 OUTPUT "Minimum value is ", Min
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

