Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.
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.
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]
DECLARE Data : ARRAY[1:120] OF REAL
Array bounds [1:120] [1]
Data type REAL for values with decimals [1]
▶ Starts at Q2 (27:32)
Starts at Q2 (27:32) · 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.