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 08 IF List[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
- (a)Give a line number for each of these types of statement: Assignment statement Selection statement Iteration statement[3]
- (b)Identify the line numbers of the three errors in the pseudocode and suggest a correction for each error.[3]
Mark scheme
Marking points from the official mark scheme (May/June 2024). The mark or mark type is shown in brackets.
- 01//02//06//10
- 04(07) and/or 08
- 03(12)
- 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
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →