AQA A-Level Computer Science AS Paper 1, June 2025: Question 13
3 marks · Medium difficulty · Short Answer
Explain why it is sometimes necessary to set ValidDirection to false after it has been set to true by calling CheckDirection in the subroutine PirateWalks.
Practise this questionQuestion
Question text
13 This question refers to the subroutine PirateWalks.
Explain why it is sometimes necessary to set ValidDirection to false after it has
been set to true by the call to the CheckDirection subroutine.
[3 marks]
Mark scheme
Show the mark scheme
13 3 marks for AO2 (analyse) 3
Direction/NumberOfSquares/distance might be valid (independently);
But the combination of these …;
… could result in Row and/or Column to be outside the boundaries of the map;
(CheckPath) would attempt to address elements beyond the bounds of the (Map)
data structure // would then malfunction/crash;
Max 3
How to answer it
Skeleton Code Analysis: PirateWalks Validation Logic
This question assesses your ability to analyse skeleton code logic (AO2) in Paper 1. Specifically, it tests your understanding of:
- Multi-stage input validation: Why validating inputs in isolation is not always sufficient.
- Boundary checking & 2D array constraints: How coordinate calculations can cause runtime errors (such as IndexOutOfBoundsException ).
- Subroutine interaction: The relationship between checking format/compass direction ( CheckDirection ) versus verifying actual path execution ( CheckPath / grid traversal).
Boundary Checking in PirateWalks
Explaining why ValidDirection must be reassessed
💡 Key Knowledge
- Isolated vs. Contextual Validity: A direction (e.g., 'N', 'S', 'E', 'W') might be a valid input on its own, and the number of squares entered might be a valid positive integer.
- Array Bounds: A grid or board is represented by a finite 2D array with specific row and column limits (e.g., 0 to MaxRow, 0 to MaxColumn).
- Runtime Exceptions: If code attempts to access indices outside valid array indices (index < 0 or index ≥ length), the program crashes or malfunctions.
✅ Model Answer (Full 3 Marks)
To gain all 3 marks, your explanation must connect the inputs to the array boundary and the resulting system failure:
- Mark 1: The direction and number of squares/distance entered might each be valid on their own (independently)...
- Mark 2: ...but the combination of this direction and distance from the current position would cause the new Row and/or Column to fall outside the boundaries of the map.
- Mark 3: Consequently, attempting to inspect the path ( CheckPath ) or update the grid would try to address elements beyond the bounds of the Map data structure, causing the program to crash or malfunction.
🧠 Exam Technique & Mark Breakdown
- Think in cause-and-effect chains:
1. Input status: Valid individually.
2. Calculated effect: Coordinates move out-of-bounds.
3. Technical consequence: Array index error / program crash. - Name specific variables and structures: Always reference identifiers directly from the skeleton code, such as Row , Column , Map , and CheckPath .
- AO2 Requirement: Broad statements like "it's not allowed" will get 0 marks. You must analyse why the code structure needs the boolean reset.
❌ Common Misconceptions & Errors
- Vagueness: Saying "the move is invalid" without explaining why (i.e. moving off the edge of the board).
- Confusing the checks: Thinking CheckDirection already checks if the pirate stays on the board. CheckDirection only checks if the character entered is a valid compass point (e.g., 'N', 'E', 'S', 'W').
- Omitting technical impact: Forgetting to mention the data structure ( Map ) or the failure mode (out-of-bounds index / crash).
- Direction / NumberOfSquares / distance might be valid (independently);
- But the combination of these ... could result in Row and/or Column being outside the boundaries of the map;
- ( CheckPath ) would attempt to address elements beyond the bounds of the ( Map ) data structure // would then malfunction / crash.
Topics
4.1 Fundamentals of programming · 4.2 Fundamentals of data structures · 4.4 Theory of computation · 4.1.1 Programming · 4.2.1 Data structures and abstract data types · 4.4.1 Abstraction and automation
Question and mark scheme from the AQA A-Level Computer Science examination, AS Paper 1, June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.