9618/23/O/N/23 question 2: worked solution (October/November 2023, paper 23)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 10.2 Arrays Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4. Q26 9618/23/O/N/23 original Q2 Structured · 9 marks Worked solution (a) Draw the flowchart in this order, joining each box to the next with an arrow: START → process box: Min ← Data [1] and MinIndex ← 1 [1] → process box: Index ← 2 , then a decision diamond Is Index > 30? that starts the loop [1] YES leads out of the loop. NO leads to a second decision diamond: Is Data[Index] < Min? [1] YES leads to a box: Min ← Data[Index] and MinIndex ← Index . NO skips it. Both go to a box Index ← Index + 1 , which loops back to the first diamond [1] When Index > 30, go to an output box: OUTPUT MinIndex , then END [1] Any loop that covers all 30 values is accepted, such as counting from 1 to 30. (b) Write both points. An array makes the algorithm simpler to write, understand, test and debug [1] A loop can be used to go through the values, with many values stored under one identifier [1] (c) DECLARE Data : ARRAY[1:120] OF REAL Array bounds [1:120] [1] Data type REAL for values with decimals [1] KEY IDEA To find a smallest value, start with the first element, compare the rest in a loop and keep its index. TOTAL 9 marks Official mark scheme VIDEO ▶ Starts at Q2 (27:32) Starts at Q2 (27:32) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.