Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Run the flowchart. Pointer is set to 1, then a letter is input. Pointer goes up by 1 each time Word[Pointer, 1] is not the letter. F is at index 6 and D is at index 4.
| Pointer | Letter | Choice | OUTPUT |
|---|---|---|---|
| 1 | F | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | Letter F is represented by Foxtrot | ||
| Another Letter? (Y or N) | |||
| Y | |||
| 1 | D | ||
| 2 | |||
| 3 | |||
| 4 | Letter D is represented by Delta | ||
| Another Letter? (Y or N) | |||
| N |
Pointer column correct [1]
Letter column correct [1]
Choice column correct [1]
OUTPUT column correct [1]
The algorithm looks at each item in turn until it finds the one it wants.
Write: (linear) search [1]
Any one problem, with its reason:
The algorithm would not stop (it keeps looping) [1]
... because an invalid character is never found in the array, so Pointer keeps going up past 13 and the program may crash [1]
▶ Whole paper
Video solution of the whole paper · by ZAINEMATICS. 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.