Cambridge AS Level Computer Science 9618 · 9.2 Algorithms

Q22 · 9618/21/O/N/22 Q3

Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2.

Q229618/21/O/N/22original Q3Structured · 5 marks
Question 3 from 9618/21/O/N/22

Worked solution

Describe the steps in order, in words, not pseudocode:

Declare a variable, for example Max, to hold the largest value. [1]

Set Max to the first element of Data (any element is fine). [1]

Set up a loop that repeats 200 times (from the start to the end of the array), using the loop counter as the array index. [1]

In the loop, if the current element is greater than Max, then assign that element to Max. [1]

After the loop, output Max. [1]

Putting the loop counter as the array index, and the "greater than" test then the assignment, are each also separate points, but the most you can score is 5.

KEY IDEAStart with the first value as the largest, compare every element in a loop, replace it when a bigger one is found, output after the loop.
TOTAL 5 marks

Official mark scheme

Mark scheme for 9618/21/O/N/22 question 3
VIDEO
▶ Whole paper

Video solution of the whole paper · by Pseudocode Pro. 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.