Computer Science · May / June 2026 · Paper 22 · Question 5
0478
As printed in the paper
The question as text
The purpose of this pseudocode algorithm is to find the name of a customer using an account ID, which contains letters and numbers. The name of the customer and the account ID are stored in the prepopulated two-dimensional (2D) array r. The algorithm would then output the name of the customer. For example, r contains the account ID of the first customer and r contains the name of the first customer. tqryt r ¡ ryyr¢¡ ¡ xv s~yu|£ tqryt y¤ ¡ u|~t£ty ¥ tqryt ru ¡ u|~t£ty ¦ x ~ ~ §¨© ª © © u § « x ~ ~ ru ¬ vxy y¤ ~x qrst xv ru ® ry¤ ¯ ~t| ° x ~ ~ §~± ²ª³ ©² ´ § r t|uv |t}~ y¤
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
5(a)[4]
One mark per mark point, max four
Line 03 / DECLARE AccountID : INTEGERshould be DECLARE AccountID : STRING
Line 05 / OUTPUT AccountIDshould be INPUT AccountID
Line 07 / CASE OF AccountID = Accounts[Row, 1]should be IF AccountID = Accounts[Row, 1]
Line 09 / OUTPUT "The customer’s name is ", Accounts[1, 2] should be OUTPUT "The customer’s name is ", Accounts[Row, 2] 01 DECLARE Accounts : ARRAY[1:1000, 1:2] OF STRING02 DECLARE Row : INTEGER
03 DECLARE AccountID : STRING
04 OUTPUT "Please enter an account ID "
05 INPUT AccountID
06 FOR Row ← 1 TO 1000
07 IF AccountID = Accounts[Row, 1]
08 THEN
09 OUTPUT "The customer’s name is ", Accounts[Row, 2] 10 ENDIF
11 NEXT Row
5(b)[1]
Linear search
5(c)[5]
Adding to the existing corrected algorithm
Any five from:
Use/initialise a flag at the start / before line 06Flag ← FALSE // Flag ← 0Between lines 08 and 10 (where the item has been found)Flag ← TRUE // Flag ← 1Outside the loop / after line 11 add another selection statement and outputIF Flag = False …… THEN OUTPUT "Account number not found in the array" ENDIF For example:01 DECLARE Accounts : ARRAY[1:1000, 1:2] OF STRING
02 DECLARE Row : INTEGER
03 DECLARE AccountID : STRING
DECLARE Flag : BOOLEAN
Flag ← FALSE
04 OUTPUT "Please enter an account ID "
05 INPUT AccountID
06 FOR Row ← 1 TO 1000
07 IF AccountID = Accounts[Row, 1]
08 THEN
09 OUTPUT "The customer’s name is ", Accounts[Row, 2] Flag ← TRUE
10 ENDIF
11 NEXT Row
IF Flag = FALSE
THEN
OUTPUT "Account number not found in the array"
ENDIF
OR replacing FOR loop with a WHILE loop
Any five from:
Use/initialise a flag at the start / before line 06Flag ← FALSE // Flag ← 0Between lines 08 and 10 (where the item has been found)Flag ← TRUE // Flag ← 1Outside the loop / after line 11 add another selection statement and outputIF Flag = False …… THEN OUTPUT "Account number not found in the array " ENDIFReplace lines 06 and 11 and increment counter before line 11WHILE NOT Flag AND Row <= 1000 (DO)Row ← Row + 1 and ENDWHILEFor example:
01 DECLARE Accounts : ARRAY[1:1000, 1:2] OF STRING
02 DECLARE Row : INTEGER
03 DECLARE AccountID : STRING
DECLARE Flag : BOOLEAN
Row ← 1
Flag ← FALSE
04 OUTPUT "Please enter an account ID "
05 INPUT AccountID
06 WHILE NOT Flag AND Row <= 1000 (DO)
07 IF AccountID = Accounts[Row, 1]
08 THEN
09 OUTPUT "The customer’s name is ", Accounts[Row, 2] Flag ← TRUE
10 ENDIF
Row ← Row + 1
11 ENDWHILE
IF Flag = FALSE
THEN
OUTPUT "Account number not found in the array"
ENDIF
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

