x

Revision notes for AQA GCSE Computer Science Representing algorithms. Open the guide for explanations and worked examples. Written against the AQA GCSE Computer Science (8525) specification, so the content matches what's examinable rather than general Computer Science background.

Representing algorithms

What you'll learn

  • 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.

What is an algorithm?

Before you can write code, you need a clear plan.

Definition

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.

Key Idea

Algorithm vs program

An algorithm is the plan. A program is code that carries out the plan on a computer.

The basic building blocks

Most GCSE algorithms are built from three ideas.

Sequence

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

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

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.

Solving problems systematically

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:

  1. Understand the task.
  2. Identify the inputs and outputs.
  3. Break the problem into smaller parts.
  4. Remove details that are not needed.
  5. Design the algorithm.
  6. Represent it in the required form.
  7. Trace or test it with sample data.

Decomposition

Definition

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.

Example

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.

  1. Identify the main task: calculate and output the total trip cost.
  2. 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.
  3. Put the sub-problems into a sensible order, because the calculation cannot happen until the inputs have been collected.
  4. The decomposed algorithm could become: get inputs → calculate ticket total → calculate final total → output final total.
Tip

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

Definition

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.

Example

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.

  1. Decide what the algorithm must do: compare an entered password with a stored password.
  2. Keep the data needed for that comparison: enteredPassword and storedPassword.
  3. Remove details that do not affect the decision: favourite colour and screen brightness.
  4. The abstracted problem becomes: input password → compare with stored password → output whether access is allowed.
Common Mistake

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.

Inputs, processing and outputs

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.

Definition

IPO model

The IPO model describes an algorithm in terms of Input, Processing and Output.

Example

Identifying inputs, processing and outputs

Given this pseudo-code:

length ← USERINPUT
width ← USERINPUT
area ← length * width
OUTPUT area
  1. The two USERINPUT lines are the inputs, because data is being collected and stored in variables.
  2. The line area ← length * width is processing, because it calculates a new value from the input values.
  3. The line OUTPUT area is the output, because it produces the result of the algorithm.

Ways to represent an algorithm

You may be asked to represent an algorithm in a particular form. Use the form the question asks for.

Pseudo-code

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

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.

Flowcharts

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.

Flowchart symbols and a pass or try again example

Common Mistake

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.

Example

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".

  1. Identify the input: the algorithm needs one value, mark.

  2. Identify the decision: compare mark with 50 using the condition mark >= 50.

  3. Choose the two possible outputs: "Pass" when the condition is true, and "Try again" when it is false.

  4. Write the selection using IF, ELSE and ENDIF.

    mark ← USERINPUT IF mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Try again" ENDIF

Determining the purpose of an algorithm

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.

Example

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
  1. The first input, 12, is stored in highest. This sets the starting value before the loop begins.
  2. The loop runs three times, so it reads the remaining three inputs: 7, 19 and 14.
  3. Each time, compare the new score with the current highest. Only update highest if the new score is greater.
StageNew scoreTest resulthighest after stage
Start-first input used12
Loop 177 > 12 is false12
Loop 21919 > 12 is true19
Loop 31414 > 19 is false19
  1. The final output is 19, so the purpose of the algorithm is to output the highest of the four input scores.
Tip

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.

Choosing between representations

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.

Exam technique

In the exam

  1. Start by identifying the inputs, processing and outputs before writing the full algorithm.
  2. Use the representation requested: pseudo-code, program code or flowchart.
  3. For pseudo-code, use clear AQA-style structures such as IF...ENDIF, FOR...ENDFOR, WHILE...ENDWHILE, REPEAT...UNTIL, ←, DIV and MOD.
  4. When asked for the purpose of an algorithm, use a trace table if there is a loop or several changing variables.
  5. Use meaningful variable names so your logic is easy to follow.
Self review

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?

Recap questions

Test yourself with 5 quick questions on this guide. Answer them all correctly to complete it.

You've reached the end

Test yourself on this topic, or move on to the next guide.

Practice questionsTake a quick quiz on this topicFlashcardsSelf-test with active recall
Efficiency of algorithmsUp next

How was this guide?

Representing algorithms Revision Guide

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms