Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 4 of 8.
Read each line and compare it with what the algorithm should do. Write the line, the error and the fix.
Line 08 PassCheck ← TRUE is wrong, because a password that is too short must fail. Correction: PassCheck ← FALSE [1]
Line 12 IF Password <> Password can never be true. Correction: IF Password <> Password2 (or IF Password2 <> Password) [1]
Line 18 UNTIL PassCheck OR Attempt <> 3 stops after the first attempt. Correction: UNTIL PassCheck OR Attempt = 3 (or Attempt >= 3) [1]
Two checks are used:
Type of check 1: validation, a length check [1]
Description: checks the number of characters, that the password has at least 8 characters [1]
Type of check 2: verification, double entry [1]
Description: the password is entered twice and the two entries are compared to see that they are the same [1]
Choose two different sets of data. Each reason must follow from the data chosen. For example:
Set 1: a short password such as small [1]
Reason: it is abnormal data, so it will be rejected by the length check [1]
Set 2: password entered, and password entered again [1]
Reason: it is normal data, so it will be accepted [1]
Any appropriate sets score, if the two sets and the two reasons are different.
▶ 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.