Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 7 of 8.
Compare each line with what the algorithm should do.
Error 1: line 01. Correction: HighestMark ← 0 (it must start low, not at 100) [1]
Error 2: line 07. Correction: INPUT Mark[Count] (the index is Count, not Counter) [1]
Error 3: line 10. Correction: HighestMarkStudents ← HighestMarkStudents + 1 (add 1, not take away) [1]
Error 4: line 14. Correction: HighestMark ← Mark[Count] (the new highest mark is stored in HighestMark) [1]
Add a lowest-mark version of the highest-mark code.
LowestMark ← 100
LowestMarkStudents ← 0
FOR Count ← 1 TO 35
IF Mark[Count] = LowestMark
THEN
LowestMarkStudents ← LowestMarkStudents + 1
ENDIF
IF Mark[Count] < LowestMark
THEN
LowestMarkStudents ← 1
LowestMark ← Mark[Count]
ENDIF
NEXT Count
OUTPUT "There are ", LowestMarkStudents, " with the lowest mark of ", LowestMarkAdd a variable LowestMark [1]
Set it to a high value, for example 100 [1]
Add a variable LowestMarkStudents [1]
Set it to zero [1]
Check if Mark[Count] = LowestMark and, if true, add 1 to LowestMarkStudents [1]
Check if Mark[Count] < LowestMark and, if true, set LowestMarkStudents to 1 and LowestMark to Mark[Count]. Add an extra output statement for both values. [1]
▶ Whole paper
Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.