AQA · GCSE · Computer Science · Higher
Rewriting a condition without NOT
Figure 2 shows an algorithm, represented using pseudo-code. Line numbers are included but are not part of the algorithm.
| 1 | num ← USERINPUT |
| 2 | IF NOT(num > 1) OR num > 20 THEN |
| 3 | OUTPUT "False" |
| 4 | ELSEIF num > 1 AND num < 15 THEN |
| 5 | OUTPUT "Almost" |
| 6 | ELSEIF num MOD 5 = 0 THEN |
| 7 | OUTPUT "True" |
| 8 | ELSE |
| 9 | OUTPUT "Unknown" |
| 10 | ENDIF |
Rewrite line 2 from the algorithm in Figure 2 without using the NOT operator. The algorithm must still have the same functionality.
Write your answer first. You can study the marking guidance whenever you need it.
Study the marking See what earns credit and compare it with a full-mark answer.
Marking points
- 1 Replaces NOT(num > 1) with an equivalent boundary test that includes 1, while retaining OR num > 20.
Full-mark answer
IF num ≤ 1 OR num > 20 THEN
Why this answer loses marks
I removed NOT but changed the connector between the two tests as well.
Only the negated comparison should be inverted; changing the connector changes which inputs reach the branch.