Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Run the flowchart for each input. Reject if the value is not from 50 to 100. If it is, Diff1 = 100 - Value and Diff2 = Value - 50. If either difference is less than 1 the output is Extreme, otherwise Normal. The algorithm stops at -1.
| Value | Diff1 | Diff2 | OUTPUT |
|---|---|---|---|
| 50 | 50 | 0 | Accept: Extreme |
| 75 | 25 | 25 | Accept: Normal |
| 99 | 1 | 49 | Accept: Normal |
| 28 | Reject: Abnormal | ||
| 82 | 18 | 32 | Accept: Normal |
| 150 | Reject: Abnormal | ||
| -1 |
Value column correct [1]
Diff1 column correct [1]
Diff2 column correct [1]
OUTPUT column correct [1]
The data after -1 (672 and 80) is never read.
Write two of these:
It outputs the type of test data (normal, extreme or abnormal) [1]
It does this with a range check, testing if the number is from 50 to 100 inclusive [1]
▶ 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.