Skip to content
VirtusAcademy

Interpreting and Correcting Algorithms

FoundationHigherAQA

Learn Interpreting and Correcting Algorithms for GCSE Computer Science with this free worksheet and full mark scheme — Foundation and Higher exam-style questions with worked answers for AQA GCSE Computer Science (8525). You may be asked to work out what an algorithm does, or to find and fix an error in it.

Free downloads

These worksheets and mark schemes are original, written for Virtus Academy and checked against the current AQA specification. Every worksheet comes with a full mark scheme.

Topic overview

Interpreting an algorithm means working out what it does; correcting one means finding and fixing an error in it.

Three types of error must be distinguished. A syntax error breaks the rules of the language, so the program will not run at all. A logic error lets the program run but produces the wrong output. A runtime error causes the program to crash while running, such as dividing by zero.

To interpret an unfamiliar algorithm, trace it with a small set of test values and see what emerges. To correct one, identify what the output should be, compare with what it actually is, then locate the statement responsible. Stating both the error and the correction is what earns full marks.

Revision notes

The three error types

Syntax error: breaks the rules of the language, so the program will not run.

Logic error: the program runs but produces the wrong output. Runtime error: the program crashes while running, for example on a division by zero.

Interpreting an algorithm

Trace it with small, simple test values and see what it produces.

Look at what the output depends on. A description such as 'it outputs the largest of the three numbers' is what interpretation questions want, rather than a line-by-line restatement.

Correcting an algorithm

Identify what the output should be, compare it with what the algorithm actually produces, then find the statement responsible.

State both the error and the correction. Common culprits are the wrong comparison operator, an off-by-one loop bound, or an incorrectly initialised variable.

Key points

  • A syntax error stops the program running.
  • A logic error gives the wrong output.
  • A runtime error crashes the program.
  • Trace with test values to interpret an algorithm.
  • Compare expected output with actual output.
  • State both the error and the correction.

Worked examples

Example 1

An algorithm runs but always outputs a value one too small. State the type of error. [1 mark]

Working

A logic error, because the program runs but produces the wrong outputidentify the error type

Example 2

A program crashes when the user enters zero as a divisor. State the type of error and explain. [2 marks]

Working

A runtime erroridentify the error type
because the program runs successfully until the division by zero occurs, at which point it crashesexplain why

Example 3

A loop should run 10 times but runs 9. State the likely cause and the correction. [2 marks]

Working

The loop bound is off by one, for example FOR i ← 1 TO 9 instead of 1 TO 10identify the error
Change the upper bound to 10 so the loop runs the correct number of timesstate the correction

Common mistakes

  • Confusing logic and syntax errors.

    Syntax stops it running; logic gives wrong output while running.

  • Identifying an error without correcting it.

    Questions usually want both.

  • Restating the code line by line.

    Interpretation means saying what the algorithm achieves overall.

  • Not tracing before answering.

    A quick trace with test values is far more reliable than reading.

Exam tips

  • Learn the three error types and how each behaves.
  • Trace with simple test values before answering.
  • Describe what an algorithm achieves, not each line.
  • Give both the error and the correction.

Key terms

Syntax error
An error breaking the language rules, stopping the program running.
Logic error
An error producing incorrect output.
Runtime error
An error causing a crash during execution.
Off-by-one
A loop running one time too many or too few.

Written and reviewed against the current AQA specification. Spotted an error? Let us know.