Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Follow the flowchart one input at a time. Counter goes up by 1 after each input is dealt with. Serve goes up only when the temperature is from 63 to 86. Hot goes up when Temp is above 86. Cold goes up when Temp is below 63.
| Counter | Hot | Cold | Serve | Temp | Error | OUTPUT |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |||
| 1 | 1 | 75 | ||||
| 2 | 2 | 78 | ||||
| 3 | 3 | 84 | ||||
| 4 | 1 | 87 | Too Hot | |||
| 5 | 2 | 91 | Too Hot | |||
| 6 | 4 | 80 | ||||
| 7 | 5 | 75 | ||||
| 8 | 6 | 70 | ||||
| 9 | 7 | 65 | ||||
| 10 | 1 | 62 | Too Cold | |||
| -1 | 30 | 30 |
At -1 the algorithm works out Error = ((2 + 1) / 10) * 100 = 30, outputs it and ends. The input 20 is never read.
Counter column correct [1]
Hot column correct [1]
Cold column correct [1]
Serve column correct [1]
Temp column correct [1]
Error column correct [1]
OUTPUT column correct [1]
Add a message to explain the number that is output.
Write: output a message such as "The percentage of meals not served" with the value (or output Hot, Cold and Serve as well) [1]
Look for a process that never changes any output.
Write: the Serve ← Serve + 1 process (updating Serve) is not needed, because Serve is never used in the output or in Error [1]
▶ Whole paper
Video solution of the whole paper · 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.