AQA GCSE Computer Science Paper 1 (1A), June 2025: Question 9
2 marks · Medium difficulty · Multiple Choice
Identify which of the five given pseudo-code algorithms correctly calculate the total of the five values in an array.
Practise this questionQuestion
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
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 Array Iteration & Totalling Algorithms
What this question tests
This question assesses your ability to trace pseudo-code and evaluate whether loops correctly traverse a 1D array. You must be able to recognize 0-based array indexing, check loop boundary conditions (start and end bounds), ensure loop counters are properly incremented, and spot logical traps such as unreachable code or out-of-bounds indexing.
Question 09: Complete the Table
Total Marks: [2 marks] (AO2 Apply)
✅ Correct Answer
| Outcome | Algorithm | ||||
|---|---|---|---|---|---|
| A | B | C | D | E | |
| Algorithm totals the five values | ✓ | ✓ | |||
| Algorithm does not total the five values | ✓ | ✓ | ✓ |
• 1 mark (MP1): Any three columns ticked correctly.
• 2 marks (MP2): All five columns ticked correctly.
Note: Reject (do not award) a column if more than one box is ticked in that column.
📐 Algorithm-by-Algorithm Walkthrough
- Algorithm A (WORKS):
Uses a WHILE counter < 5 loop starting at counter ← 0 .
Values traversed: index 0, 1, 2, 3, 4 . Each value is added to total , and counter increases by 1 each time. Loop terminates when counter = 5 . All 5 elements are totalled. - Algorithm B (WORKS):
Uses FOR a ← 0 TO LEN(numbers) - 1 .
Since LEN(numbers) = 5 , the loop runs from 0 TO 4 . This matches the exact index range of the 5 elements in a 0-indexed array. - Algorithm C (FAILS):
Uses FOR a ← 1 TO 7 .
Two major errors: It starts at index 1 (missing the first item at numbers[0] = 44) and tries to go up to index 7 , which causes an "Index Out of Bounds" runtime error because the last valid index is 4. - Algorithm D (FAILS):
Initialises total ← 0 , followed immediately by WHILE total > 0 .
Because total is 0, the condition 0 > 0 evaluates to False on entry. The loop body never runs at all! Additionally, it attempts to use numbers[total] , which uses the accumulated sum as an array index. - Algorithm E (FAILS):
Initialises x ← 1 and uses a REPEAT ... UNTIL x = 5 loop.
Two major errors: First, it starts at index 1 instead of 0 (omitting the first number). Second, x is never updated inside the loop, creating an infinite loop where x is always 1 and never reaches 5.
💡 Key Knowledge: Array Indexing
- 0-indexed arrays: In AQA pseudo-code (and Python), arrays start at index 0 .
- For an array of length n :
• First index = 0
• Last index = n - 1 - LEN(array) returns the total count of items (5), not the final index (4).
🧠 Exam Technique: Loop Checklist
- Check Start Index: Does it start at 0 to include the first item?
- Check End Condition: Does it stop at index 4 (or < 5 )?
- Check the Step: Is the counter variable actually incremented inside a WHILE or REPEAT loop?
- Initial Conditions: Check if a WHILE loop condition is true before entry.
❌ Common Student Traps
- Assuming 1-based indexing: Thinking Algorithm C is correct because it has numbers "1 to...". Always remember arrays begin at 0!
- Overlooking infinite loops: Failing to notice that Algorithm E never changes x .
- Double-ticking: Putting ticks in both boxes in the same column automatically forfeits the mark for that column.
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 (1A), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.