AQA A-Level Computer Science Paper 1, June 2025: Question 7

3 marks · Medium difficulty · Short Answer

Explain limitations and behavior of the EvaluateRPN subroutine, including identifying an expression causing evaluation failure and explaining the role of its final selection structure.

Practise this question

Question

Question 07 focuses on the EvaluateRPN subroutine. Part 07.1 asks students to describe an infix expression that would cause CheckIfUserInputValid to return True and could be successfully converted to RPN by ConvertToRPN, but would not be evaluated correctly by EvaluateRPN, worth 1 mark. Part 07.2 asks students to explain the purpose of the final selection structure in EvaluateRPN, including what the possible returned values represent, worth 2 marks.
Question text

07 This question is about the EvaluateRPN subroutine.

07.1 Describe an infix expression that:

• would cause the subroutine CheckIfUserInputValid to return True and

• could be successfully converted to RPN by the ConvertToRPN subroutine

but that would not be evaluated correctly by the EvaluateRPN subroutine.

[1 mark]

07.2 Explain the purpose of the final selection structure in the EvaluateRPN subroutine.

Your explanation should include a description of what the possible values returned by

the subroutine represent.

[2 marks]

Mark scheme

Show the mark scheme Mark scheme for Question 07. For 07.1 (1 mark): Division by zero OR when the result of a calculation is too large to be represented with the data type used. For 07.2 (2 marks): Checks that the result of the expression is a whole number/integer (1 mark); Returns either the evaluation of the expression or -1 to indicate that the evaluation was not a whole number/integer (1 mark).

Question Marks

07 1 Mark is for AO2 (analyse) 1

Division by zero;

When the result of a calculation is too large to be represented with the data type

used;

Max 1

07 2 All marks AO2 (analyse) 2

Checks that the result of the expression is a whole number/integer;

Returns either the evaluation of the expression or –1, to indicate that the evaluation

was not an whole number/integer;

How to answer it

Evaluating RPN Subroutine Logic & Edge Cases

📌 What this question tests

This question evaluates your understanding of the Paper 1 Skeleton Code's infix-to-RPN evaluation system, specifically:

  • Validation boundaries: Distinguishing between structural/syntactic validation (handled prior to evaluation) and runtime/semantic arithmetic limits.
  • Runtime mathematical exceptions: Identifying calculations that parse successfully but fail during evaluation (e.g., division by zero or numeric overflow).
  • Subroutine return contracts: Understanding how sentinel return values (e.g., returning -1 ) communicate execution states and type constraints.
Question 07.1 • 1 Mark

Infix Expressions Causing Evaluation Failure

Identify an expression valid for parsing and conversion that fails during evaluation

✅ Correct Answers (Any 1)

  • An expression containing division by zero (e.g., 5 / 0 or 10 / (3 - 3) ).
  • An expression where the result of a calculation is too large to be represented by the data type used (arithmetic / integer overflow).

💡 Key Knowledge

The subroutine CheckIfUserInputValid checks syntax rules (e.g., matching parentheses, valid operator placements, and allowed characters). It does not evaluate values dynamically.

Consequently, 4 / 0 has flawless syntax and converts to RPN ( 4 0 / ), but crashes or fails inside EvaluateRPN when the division operation is executed.

🧠 Exam Technique

Always look at where responsibilities lie across the pipeline:

Input Check → Conversion → Evaluation

To break the last step without failing the first two, look for a semantic / runtime math error rather than a structural or grammatical error.

❌ Common Errors

  • Syntax errors: Stating expressions like 5 + + 2 or unbalanced brackets — these get caught earlier by CheckIfUserInputValid .
  • Unsupported operators: Supplying symbols like ^ or % that fail the allowed character check.
Mark Scheme Breakdown:
[1 mark] Division by zero OR result too large to be represented with the data type used (overflow).
Question 07.2 • 2 Marks

Purpose of the Final Selection Structure

Explain the final conditional check and describe its return values

✅ Correct Answer (2 Marks)

  • Mark 1: Checks that the final calculated result of the expression is a whole number / integer.
  • Mark 2: Returns either the evaluated result (if valid/integer) or -1 to indicate that the evaluation did not result in a whole number.

🧠 Exam Technique: Two-Part Prompt

The prompt has two clear instructions:

  1. "Explain the purpose..." → Check for integer result.
  2. "Include a description of what the possible values returned... represent." → Define what returning the number means vs what returning -1 means.

Students often lose Mark 2 by stating it returns -1 without explaining why (it acts as an error indicator for non-integer results).

💡 Key Knowledge: Sentinel Values

In the skeleton code, integer division or fractional results (such as 5 / 2 = 2.5 ) are not permitted as valid final answers. The final IF statement compares the result against its rounded or integer-cast counterpart.

If the result has a fractional component, the subroutine uses -1 as an error flag (sentinel value).

❌ Common Misconceptions

  • Vaguely stating "it checks if the answer is valid" without specifying integer / whole number.
  • Failing to mention the specific sentinel value ( -1 ) or confusing it with a negative calculation result.
Mark Scheme Breakdown:
1 mark: Checks that the result of the expression is a whole number/integer.
1 mark: Returns either the evaluation of the expression or -1, to indicate that the evaluation was not a whole number/integer.

Topics

4.1 Fundamentals of programming · 4.3 Fundamentals of algorithms · 4.4 Theory of computation · 4.1.1 Programming · 4.3.3 Reverse Polish · 4.4.1 Abstraction and automation

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