Cambridge O Level Computer Science 2210 · 7.8 Identifying and correcting errors in algorithms

Q69 · 2210/22/O/N/22 Q5

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 7 of 8.

Q692210/22/O/N/22original Q5Structured · 8 marks
Question 5 from 2210/22/O/N/22

Worked solution

(a)

Four errors, each with its correction. Write any four of these:

Error: line 09 stores MarksEntry. Correction: Higher[HighList] ← Mark [1]

Error: line 15 does not change MidList. Correction: MidList ← MidList + 1 [1]

Error: line 17 uses the wrong counter. Correction: Lower[LowList] ← Mark [1]

Error: line 22 uses NEXT with a condition. Correction: UNTIL MarksEntry = 500 [1]

(b)

Ask the user after each mark whether to carry on, and stop when they say no. Write this at the end of the loop, replacing line 22:

OUTPUT "Do you want to enter another mark?"
INPUT AnotherMark
UNTIL AnotherMark = "No"

A question is output and an answer is input to decide whether to end [1]

These statements are placed at the end of the loop, after the marks are stored [1]

The test UNTIL AnotherMark = "No" replaces line 22 [1]

Remove the MarksEntry counter, lines 04 and 21, as it is no longer needed [1]

Other correct ways score, for example a WHILE loop with AnotherMark = "Yes", or ending when Mark = -1.

KEY IDEARead the pseudocode line by line and check each assignment, counter and loop ending.
TOTAL 8 marks

Official mark scheme

Mark scheme for 2210/22/O/N/22 question 5
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. 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.