AQA GCSE Computer Science Paper 1 (1B), June 2025: Question 9

2 marks · Medium difficulty · Multiple Choice

Identify which of the five pseudo-code algorithms correctly calculate the total of five values stored in an array.

Practise this question

Question

Figure 9 shows five pseudo-code algorithms labelled A to E, each attempting to sum the five values in the array numbers = [44, 1, 2, 14, 68]. Algorithm A uses a WHILE loop from counter = 0 to counter < 5. Algorithm B uses a FOR loop from 0 to LEN(numbers) - 1. Algorithm C uses a FOR loop from 1 to 7. Algorithm D uses a WHILE loop with condition total > 0. Algorithm E uses a REPEAT UNTIL loop with x = 1 and UNTIL x = 5 without incrementing x. Below, a table asks the student to tick whether each algorithm A, B, C, D, and E totals the five values or does not total the five values.
Question text

09 Figure 9 shows five algorithms, represented using pseudo-code.

Figure 9

numbers [44, 1, 2, 14, 68]

counter 0

total 0

WHILE counter < 5

A index counter

total total + numbers[index]

counter counter + 1

ENDWHILE

OUTPUT total

numbers [44, 1, 2, 14, 68]

total 0

FOR a 0 TO LEN(numbers) - 1

B

total total + numbers[a]

ENDFOR

OUTPUT total

numbers [44, 1, 2, 14, 68]

total 0

FOR a 1 TO 7

C

total total + numbers[a]

ENDFOR

OUTPUT total

numbers [44, 1, 2, 14, 68]

total 0

WHILE total > 0

D

total total + numbers[total]

ENDWHILE

OUTPUT total

numbers [44, 1, 2, 14, 68]

total 0

x 1

E REPEAT

total total + numbers[x]

UNTIL x = 5

OUTPUT total25

The algorithms in Figure 9 have been written to calculate the total of the five values

in the array numbers. Not all of the algorithms work.

Complete the table by ticking ( ) one box in each column (A–E).

[2 marks]

Algorithm

*24* A B C D E

Algorithm totals the five values

Algorithm does not total the five values

Mark scheme

Show the mark scheme Mark scheme for Question 09 allocating 2 marks: 1 mark for any three columns correct, 2 marks for all five columns correct. The correct entries are: Algorithm A totals the five values; Algorithm B totals the five values; Algorithm C does not total the five values; Algorithm D does not total the five values; Algorithm E does not total the five values. Reject a column if more than one tick is present.

Total

Question Part Marking guidance

marks

09 2 marks for (AO2 apply) 2

MP1: for any three columns correct;

MP2: for all columns correct;

A B C D E

Algorithm totals the five values ✔ ✔

Algorithm does not total the five values ✔ ✔ ✔

R. column if more than 1 tick in that column

How to answer it

Evaluating Pseudo-Code Algorithms: Array Totalling

📌 What this question tests

This question assesses your ability to trace pseudo-code, understand iteration (loops), and recognise how array indexing works in computer science. You must spot syntax logic bugs such as infinite loops, off-by-one index errors, and condition test failures.

Question 09 Breakdown

Total Marks: 2 (AO2 - Application)

✅ Correct Completed Table

Outcome Algorithm
A B C D E
Algorithm totals the five values ✓ ✓
Algorithm does not total the five values ✓ ✓ ✓
Mark Scheme Allocation:
  • 1 mark: Any 3 columns correctly ticked.
  • 2 marks: All 5 columns correctly ticked.
  • Note: If you put more than one tick in any column, that column is rejected and cannot count towards your mark!

📐 Algorithm-by-Algorithm Walkthrough

The array is numbers ← [44, 1, 2, 14, 68] . Because arrays are zero-indexed, the 5 valid indices are 0, 1, 2, 3, 4.

Algorithm A: Works ✓

Loop: WHILE counter < 5 starting at 0 .

Trace: Runs for counter = 0, 1, 2, 3, 4 . Increments by 1 each time. Stops when counter = 5 .

Result: Adds elements at indices 0, 1, 2, 3, and 4. All 5 numbers are totalled correctly.

Algorithm B: Works ✓

Loop: FOR a ← 0 TO LEN(numbers) - 1 .

Trace: LEN(numbers) is 5, so the loop runs from 0 TO 4 inclusive.

Result: Accesses each valid index from 0 to 4 in turn. Successfully totals all five values.

Algorithm C: Fails ✗

Loop: FOR a ← 1 TO 7 .

Trace: Starts at index 1 (skipping index 0: 44 ). Then tries to access index 5, 6, 7 which don't exist!

Result: Misses the first element and causes an Index Out of Bounds / Range Error.

Algorithm D: Fails ✗

Loop: WHILE total > 0 .

Trace: total is set to 0 immediately before the loop. The condition 0 > 0 is False right from the start.

Result: The loop body never executes even once! Also incorrectly uses numbers[total] .

Algorithm E: Fails ✗

Loop: REPEAT ... UNTIL x = 5 .

Trace: x starts at 1, but x is never incremented inside the loop!

Result: Causes an infinite loop adding numbers[1] forever. It also starts at 1 instead of 0.

💡 Key Knowledge to Remember

  • Zero-Indexing: Array items are indexed starting at 0 . For an array of size N, valid indices run from 0 to N - 1 .
  • Array Length: If LEN(numbers) = 5 , the last item is at position LEN(numbers) - 1 = 4 .
  • Condition-Controlled Loops: A WHILE loop tests the condition before running. If the condition is false initially, the loop never runs.
  • Post-Condition Loops: A REPEAT...UNTIL loop always runs at least once, testing the condition at the end.

🧠 Exam Technique: How to Trace Fast

  • Check Start & End Values: Does the index variable start at 0 ? Does it reach 4 without exceeding it?
  • Look for Missing Updates: Check whether loop counters ( counter or x ) actually get updated inside WHILE or REPEAT loops. If not, it's an infinite loop!
  • One Tick per Column: Never tick both rows in the same column—the mark scheme strictly instructs examiners to reject multi-ticked columns.

❌ Common Errors Made by Students

  • Assuming 1-based indexing: Thinking Algorithm C is correct because it starts counting at 1.
  • Overlooking uninitialised / unmet conditions: Believing Algorithm D adds values without checking that total > 0 is immediately false.
  • Missing the infinite loop in E: Skimming Algorithm E and seeing UNTIL x = 5 , assuming x increases automatically like a FOR loop.

Topics

3.1 Fundamentals of algorithms · 3.2 Programming · 3.1.1 Representing algorithms · 3.2.2 Programming concepts · 3.2.6 Data structures

Question and mark scheme from the AQA GCSE Computer Science examination, Paper 1 (1B), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.