GGCSE Revision Hub

3.1.1 Representing algorithms

AQA Computer Science 8525Topic 3.1 — Fundamentals of algorithmsFoundation & Higher

An algorithm is a sequence of steps that can be followed to complete a task. This topic is about how algorithms are written down, how they are built out of smaller parts, and how you judge whether one is better than another. It is the foundation of Paper 1: almost every programming question assumes you can do what is set out here. Learn it as a set of tools for thinking — decomposition, abstraction, tracing and comparing — rather than as a list of definitions.

What you need to know

What an algorithm is

An algorithm is a sequence of steps that can be followed to complete a task. That definition is deliberately loose, because an algorithm does not have to be for a computer: a recipe and a set of directions for a treasure hunt are both algorithms. The important part is that the steps are unambiguous, so that somebody following them gets the same result every time.

Key fact: An algorithm is a sequence of steps that can be followed to complete a task.

An algorithm is not a program

A computer program is an implementation of an algorithm. The algorithm is the idea; the program is one particular way of writing that idea down for a particular language on a particular machine. The same algorithm can be implemented in Python, in C# or in VB.NET, and can also be written as a flowchart or as pseudo-code. This distinction is worth remembering because exam questions often give you an algorithm in one form and ask about another.

Key fact: A program is an implementation of an algorithm; the algorithm is the idea, not the code.

Decomposition

Decomposition means breaking a problem into a number of sub-problems, so that each sub-problem accomplishes an identifiable task, which might itself be further subdivided. It is how you make a hard problem tractable: instead of one enormous problem, you get a set of smaller ones that you can write, test and reuse. If you can name each part, you can write each part.

Key fact: Decomposition breaks a problem into identifiable sub-problems, each of which can be solved separately.

Abstraction

Abstraction is the process of removing unnecessary detail from a problem. It is the opposite move to decomposition: decomposition says 'split this up', abstraction says 'ignore the details that do not matter'. Deciding what to leave out is the hard part, and getting it wrong is why a program built on the wrong abstraction will be wrong however well it is coded.

Key fact: Abstraction is removing unnecessary detail from a problem.

Three ways to write an algorithm down

You must be able to use a systematic approach to problem solving and algorithm creation, representing the algorithms using pseudo-code, program code and flowcharts. Any exam question where students are given pseudo-code will use the AQA standard version, and the question will indicate the form of response expected. That last point matters: if a question says 'write pseudo-code', Python is not an acceptable answer even if it is correct.

Key fact: Know pseudo-code, program code and flowcharts — and give the form the question asks for.

Inputs, processing and outputs

Explain simple algorithms in terms of their inputs, processing and outputs, and be able to identify where each of them is taking place within an algorithm. Inputs are what goes in, outputs are what comes out, and processing is everything in between. This three-part split is a reliable way to read any unfamiliar algorithm, and it is also the fastest way to answer a question about what a program does.

Key fact: Every algorithm can be read as inputs, processing and outputs.

Tracing an algorithm

Determine the purpose of simple algorithms using trace tables and visual inspection. A trace table is a grid: one column per variable, one row per step, and you fill in what each variable holds after each line. It turns 'read the code' into 'watch it run', and it is the single most useful skill in this topic for a question you have never seen before.

Key fact: Use a trace table to watch an algorithm run, one row per step.

Flashcards

Exam questions

Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.

mcq1 mark

Which term means 'the process of removing unnecessary detail from a problem'?

  • Decomposition
  • Abstraction
  • Trace table
  • Implementation

Mark scheme: 1 mark for identifying abstraction. Decomposition splits a problem into sub-problems, a trace table is a grid used to trace an algorithm, and implementation is turning an algorithm into a program.

short3 marks

Explain in English the difference between decomposition and abstraction, and give an example of each.

Mark scheme: 1 mark for stating that decomposition breaks a problem into identifiable sub-problems. 1 mark for stating that abstraction removes unnecessary detail from a problem. 1 mark for giving a correct example of each, for example breaking a booking system into search, select and pay, and ignoring screen size when modelling the booking itself.

six6 marks

You are given an algorithm you have never seen before, written in AQA standard pseudo-code. Explain in English how you would work out what it does.

Mark scheme: Level 1 (1-2 marks): A short answer saying you would read it and use a trace table. Level 2 (3-4 marks): A structured answer covering the trace table method, identifying inputs, processing and outputs, and checking the result against what the algorithm is supposed to do. Level 3 (5-6 marks): A detailed answer describing how to set up the trace table with a column per variable and a row per statement, how to work through the statements in order including the conditions and loops, how to spot the inputs and the outputs of the whole algorithm, and how to check the outcome against the stated purpose to determine what the algorithm is for, including the point that an algorithm can be written in pseudo-code, program code or a flowchart and the same trace method works for all three.

Other sections in this topic

Practise these questions

Answer them in the interactive view and they get marked against the same mark scheme, one mark at a time, with the reason for each mark.

Open the interactive topic →