- What an algorithm is, and why it is not the same as a computer program.
- How decomposition and abstraction help you solve problems systematically.
- How to represent algorithms using pseudo-code, program code and flowcharts.
- How to explain algorithms using inputs, processing, outputs and trace tables.
Before you can write code, you need a clear plan.
Algorithm
An algorithm is a sequence of steps that can be followed to complete a task.
An algorithm does not have to be written in a programming language. It might be written as pseudo-code, drawn as a flowchart, or described in numbered steps.
A computer program is an implementation of an algorithm. An implementation is a working version written in a real programming language, such as Python 3, C# or VB.NET.
Algorithm vs program
An algorithm is the plan. A program is code that carries out the plan on a computer.
Most GCSE algorithms are built from three ideas.
Sequence means instructions happen in order, one after another.
For example:
length ← USERINPUT
width ← USERINPUT
area ← length * width
OUTPUT area
The computer starts at the top and follows each line in order.
Selection means the algorithm makes a decision. A condition is a test that is either true or false.
IF mark >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Try again"
ENDIF
The condition is mark >= 50. The algorithm chooses one path depending on whether that condition is true.
Iteration means repetition. A repeated section of an algorithm is called a loop.
FOR count ← 1 TO 5
OUTPUT "Hello"
ENDFOR
This loop outputs "Hello" five times.
A systematic approach means you do not just start typing code and hope. You work through the problem in an organised way.
A good approach is:
- Understand the task.
- Identify the inputs and outputs.
- Break the problem into smaller parts.
- Remove details that are not needed.
- Design the algorithm.
- Represent it in the required form.
- Trace or test it with sample data.
Decomposition
Decomposition means breaking a problem into smaller sub-problems, where each sub-problem does an identifiable task.
A sub-problem might itself be broken down further. This makes a large problem much easier to design, test and explain.
Decomposing a ticket price calculator
A school wants an algorithm to calculate the total cost of a trip. Each pupil pays for a ticket, and there is one fixed coach cost.
- Identify the main task: calculate and output the total trip cost.
- Break the task into smaller sub-problems: input the number of pupils, input the ticket price, input the coach cost, calculate the pupil ticket total, add the coach cost, then output the final total.
- Put the sub-problems into a sensible order, because the calculation cannot happen until the inputs have been collected.
- The decomposed algorithm could become: get inputs → calculate ticket total → calculate final total → output final total.
Use verb phrases
When decomposing, name sub-problems with clear verb phrases such as get pupil number, calculate total, or display result. This helps you turn them into algorithm steps later.
Abstraction
Abstraction is the process of removing unnecessary detail from a problem, so you can focus on what matters.
In Computer Science, you often ignore real-world details that do not affect the algorithm.
For example, if you are writing an algorithm to calculate the area of a rectangle, you need the length and width. You do not need the colour of the rectangle, who drew it, or what room it is in.
Choosing relevant details
A login system should allow access only if the entered password matches the stored password. The user’s name, favourite colour and screen brightness are also available.
- Decide what the algorithm must do: compare an entered password with a stored password.
- Keep the data needed for that comparison:
enteredPassword and storedPassword.
- Remove details that do not affect the decision: favourite colour and screen brightness.
- The abstracted problem becomes: input password → compare with stored password → output whether access is allowed.
Including every detail
Do not include extra details just because they appear in the story. If a detail does not affect the inputs, processing or outputs, it probably belongs outside the algorithm.
An input is data given to an algorithm. It might come from the keyboard, a file, a sensor, or another part of a program.
Processing means the work done by the algorithm. This could include calculations, comparisons, loops or changing variable values.
An output is the result produced by the algorithm. It might be displayed on screen, printed, stored, or returned to another part of a program.
A variable is a named storage location for data that may change while the algorithm runs.
IPO model
The IPO model describes an algorithm in terms of Input, Processing and Output.
Identifying inputs, processing and outputs
Given this pseudo-code:
length ← USERINPUT
width ← USERINPUT
area ← length * width
OUTPUT area
- The two
USERINPUT lines are the inputs, because data is being collected and stored in variables.
- The line
area ← length * width is processing, because it calculates a new value from the input values.
- The line
OUTPUT area is the output, because it produces the result of the algorithm.
You may be asked to represent an algorithm in a particular form. Use the form the question asks for.
Pseudo-code is a code-like way of writing an algorithm that is not tied to one real programming language.
In AQA questions, pseudo-code uses standard structures such as:
IF condition THEN
instructions
ELSE
instructions
ENDIF
and:
FOR count ← 1 TO 10
instructions
ENDFOR
Pseudo-code should be clear enough that someone could turn it into program code.
Program code is written in a real programming language and must follow that language’s syntax rules.
For example, this Python 3 program code implements a pass/fail algorithm:
mark = int(input())
if mark >= 50:
print("Pass")
else:
print("Try again")
The algorithm idea is the same as the pseudo-code version, but the syntax is Python-specific.
A flowchart is a diagram that represents an algorithm using symbols connected by arrows. The arrows show the flow of control: the order in which steps happen.
The diagram below shows the main flowchart symbols and a simple decision algorithm.

Answering in the wrong form
If the question asks for a flowchart, do not write pseudo-code instead. If it asks for pseudo-code, do not answer in Python unless the question allows program code.
Writing a decision in pseudo-code
Write an algorithm that inputs a mark and outputs "Pass" if the mark is at least 50, otherwise outputs "Try again".
-
Identify the input: the algorithm needs one value, mark.
-
Identify the decision: compare mark with 50 using the condition mark >= 50.
-
Choose the two possible outputs: "Pass" when the condition is true, and "Try again" when it is false.
-
Write the selection using IF, ELSE and ENDIF.
mark ← USERINPUT
IF mark >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Try again"
ENDIF
To determine an algorithm’s purpose, you need to work out what task it performs overall.
Two useful methods are:
- Visual inspection: reading the algorithm carefully and spotting what it seems to do.
- Tracing: stepping through the algorithm with example data.
A trace table records the values of variables as an algorithm runs. It is especially useful for loops, because variables may change several times.
Tracing an algorithm to find its purpose
Trace this algorithm for the inputs 12, 7, 19, 14.
highest ← USERINPUT
FOR count ← 1 TO 3
score ← USERINPUT
IF score > highest THEN
highest ← score
ENDIF
ENDFOR
OUTPUT highest
- The first input, 12, is stored in
highest. This sets the starting value before the loop begins.
- The loop runs three times, so it reads the remaining three inputs: 7, 19 and 14.
- Each time, compare the new
score with the current highest. Only update highest if the new score is greater.
| Stage | New score | Test result | highest after stage |
|---|
| Start | - | first input used | 12 |
| Loop 1 | 7 | 7 > 12 is false | 12 |
| Loop 2 | 19 | 19 > 12 is true | 19 |
| Loop 3 | 14 | 14 > 19 is false | 19 |
- The final output is 19, so the purpose of the algorithm is to output the highest of the four input scores.
Trace in order
When tracing, update variables in the exact order the algorithm runs. A later line may depend on a value changed by an earlier line.
Different representations are useful for different reasons.
- Pseudo-code is good for planning logic without worrying about exact programming syntax.
- Program code is needed when the algorithm must actually run on a computer.
- Flowcharts are good for showing decisions, loops and the overall flow visually.
In an exam, the expected form will be stated. The key skill is not just knowing the symbols or keywords, but being able to express the same algorithm clearly in the requested form.
In the exam
- Start by identifying the inputs, processing and outputs before writing the full algorithm.
- Use the representation requested: pseudo-code, program code or flowchart.
- For pseudo-code, use clear AQA-style structures such as
IF...ENDIF, FOR...ENDFOR, WHILE...ENDWHILE, REPEAT...UNTIL, ←, DIV and MOD.
- When asked for the purpose of an algorithm, use a trace table if there is a loop or several changing variables.
- Use meaningful variable names so your logic is easy to follow.
Check yourself
- What is the difference between an algorithm and a computer program?
- How could you decompose an algorithm that calculates the total cost of items in a basket?
- Why is a trace table useful when an algorithm contains a loop?