Note AcademyNote Academy

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.  ‚tqryt r‘‘™š›”œ ¡ ryyr¢–¡ ž ¡Ÿ— xv s~yu|£ Ÿ ‚tqryt y™¤ ¡ u|~t£ty ¥ ‚tqryt r‘‘™š›”u‚ ¡ u|~t£ty ¦ x ~„ ~ §„¨’©œ’ ’›”’ª ©› ©‘‘™š›” u‚ § « x ~„ ~ r‘‘™š›”u‚ ¬ vxy y™¤  ~x  ­ qrst xv r‘‘™š›”u‚ ® r‘‘™š›”œ–y™¤ž — ¯ ~€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 : INTEGER

    should be DECLARE AccountID : STRING

    Line 05 / OUTPUT AccountID

    should 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 STRING

    02 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 06
    Flag ← FALSE // Flag ← 0
    Between lines 08 and 10 (where the item has been found)
    Flag ← TRUE // Flag ← 1
    Outside the loop / after line 11 add another selection statement and output
    IF 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 06
    Flag ← FALSE // Flag ← 0
    Between lines 08 and 10 (where the item has been found)
    Flag ← TRUE // Flag ← 1
    Outside the loop / after line 11 add another selection statement and output
    IF Flag = False …
    … THEN OUTPUT "Account number not found in the array " ENDIF
    Replace lines 06 and 11 and increment counter before line 11
    WHILE NOT Flag AND Row <= 1000 (DO)
    Row ← Row + 1 and ENDWHILE

    For 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.