Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Run the flowchart from START. List1 and List2 start at 0. The List input chooses which total to add Value to: 1 adds to List1, 2 adds to List2, -1 stops, anything else gives "Input Error".
| List | Value | List1 | List2 | OUTPUT |
|---|---|---|---|---|
| 0 | 0 | |||
| 2 | ||||
| 77 | 77 | |||
| 2 | ||||
| 16 | 93 | |||
| 1 | ||||
| 35 | 35 | |||
| 2 | ||||
| -7 | 86 | |||
| 5 | ||||
| 18 | Input Error | |||
| 1 | ||||
| 11 | 46 | |||
| 1 | ||||
| 12 | 58 | |||
| 2 | ||||
| 20 | 106 | |||
| -1 | List 1 = 58 | |||
| List 2 = 106 | ||||
| List 2 is greatest |
List column correct [1]
Value column correct [1]
List1 column correct [1]
List2 column correct [1]
OUTPUT column correct [1]
The last 18 is never read because -1 stops the algorithm.
▶ 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.