9618/21/O/N/22 question 3: worked solution (October/November 2022, paper 21)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 9.2 Algorithms Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2. Q22 9618/21/O/N/22 original Q3 Structured · 5 marks 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 IDEA Start 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 VIDEO ▶ Whole paper Video solution of the whole paper · by Pseudocode Pro. Tap the picture to open it on YouTube.