You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
An algorithm is a step-by-step set of instructions designed to perform a specific task or solve a particular problem. Algorithms are at the heart of every computer program, but they are not limited to computing — you follow algorithms every day, from recipes to morning routines.
Computers cannot think for themselves. They require precise, unambiguous instructions to carry out any task. An algorithm provides those instructions. Before writing any code, a programmer must first design an algorithm that clearly describes:
Every algorithm follows this fundamental shape:
graph LR
A["Input"] --> B["Process (steps of algorithm)"]
B --> C["Output"]
If the algorithm is wrong, the program will be wrong — no matter how well the code is written. This is why algorithm design is one of the most important skills in Computer Science.
A well-designed algorithm should have the following properties:
| Property | Meaning |
|---|---|
| Finite | It must eventually stop — it cannot run forever |
| Definite | Each step must be clear and unambiguous |
| Effective | Each step must be achievable (computable) |
| Has inputs | It takes zero or more inputs |
| Has outputs | It produces at least one output |
Exam Tip: If you are asked to describe what makes a good algorithm, remember these five properties. AQA and OCR mark schemes often award marks for mentioning that an algorithm must terminate and that each step must be unambiguous.
There are three main ways to represent an algorithm at GCSE level:
Writing the steps in plain English. This is easy to understand but can be ambiguous.
Example — Making a cup of tea:
A way of writing algorithms that looks like code but is not tied to any particular programming language. It uses keywords like IF, THEN, ELSE, WHILE, FOR, REPEAT, UNTIL, INPUT, OUTPUT.
Example — Check if a number is positive:
INPUT number
IF number > 0 THEN
OUTPUT "Positive"
ELSE IF number < 0 THEN
OUTPUT "Negative"
ELSE
OUTPUT "Zero"
ENDIF
A diagrammatic way of representing an algorithm using standard symbols:
| Symbol | Shape | Purpose |
|---|---|---|
| Terminator | Rounded rectangle (oval) | Start or end of the algorithm |
| Process | Rectangle | An instruction or action |
| Decision | Diamond | A yes/no question (branch) |
| Input/Output | Parallelogram | Taking input or producing output |
| Arrow | Line with arrowhead | Shows the flow of control |
Exam Tip: In the exam, always label your flowchart arrows clearly and make sure every decision box has exactly two exits — one for YES and one for NO.
Two key techniques are used when designing algorithms:
Breaking a complex problem down into smaller, more manageable sub-problems. Each sub-problem can then be solved individually.
Example: Building a game might be decomposed into:
Removing unnecessary detail and focusing only on what is important for solving the problem. This simplifies the problem without losing essential information.
Example: A map of the London Underground is an abstraction — it shows stations and connections but removes the actual geographic distances and street layouts.
Algorithms are not just for computers. Many everyday tasks follow algorithmic thinking:
Understanding algorithms helps you think logically and systematically, which is a core skill for GCSE Computer Science.
| Term | Definition |
|---|---|
| Algorithm | A step-by-step set of instructions to solve a problem |
| Pseudocode | A language-independent way of writing algorithms |
| Flowchart | A diagram representing an algorithm using standard symbols |
| Decomposition | Breaking a problem into smaller sub-problems |
| Abstraction | Removing unnecessary detail to simplify a problem |
| Sequence | Steps carried out one after another in order |
| Selection | A decision point (IF/ELSE) |
| Iteration | Repeating steps (loops) |
Imagine a teacher wants a program that takes the class register and outputs the number of pupils present, the number absent, and any pupils marked late. Before writing any code, you must decompose this problem into sub-problems, then design an algorithm for each.
Decomposition:
Pseudocode:
present = 0
absent = 0
late = 0
FOR each pupil IN classList
INPUT status
IF status = "P" THEN
present = present + 1
ELSE IF status = "A" THEN
absent = absent + 1
ELSE IF status = "L" THEN
late = late + 1
ENDIF
NEXT pupil
OUTPUT present, absent, late
Trace table for a class of 4 with inputs P, A, P, L:
| Iteration | status | present | absent | late |
|---|---|---|---|---|
| Start | — | 0 | 0 | 0 |
| 1 | P | 1 | 0 | 0 |
| 2 | A | 1 | 1 | 0 |
| 3 | P | 2 | 1 | 0 |
| 4 | L | 2 | 1 | 1 |
Output: 2, 1, 1.
Notice how decomposition transformed a vague request ("take the register") into four concrete sub-tasks. Each sub-task becomes either an input, a process, or an output — the three basic building blocks of every algorithm.
Natural-language specifications are often ambiguous. Consider: "If the student's average is at least 70 and attendance is above 90%, award a merit; otherwise if the average is at least 50, give a pass; otherwise fail." Converting this to pseudocode forces disambiguation of operator precedence and coverage of all cases.
INPUT average, attendance
IF average >= 70 AND attendance > 90 THEN
OUTPUT "Merit"
ELSE IF average >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
Trace table for three test cases:
| average | attendance | Branch entered | Output |
|---|---|---|---|
| 85 | 95 | Merit | Merit |
| 85 | 80 | Pass (first condition fails) | Pass |
| 45 | 99 | Fail (both fail) | Fail |
Pseudocode makes the precedence and the fall-through behaviour explicit. It also enables a reviewer to confirm that every input case is handled — a property that natural language descriptions often obscure.
A full school timetable contains room numbers, staff codes, cover arrangements, lesson resources, bell-ring timings and much more. For a pupil's phone app you need only: day, period number, subject, room. Abstraction discards what is irrelevant. The resulting record type might be:
RECORD lessonEntry
day : STRING
period : INTEGER
subject : STRING
room : STRING
ENDRECORD
This is more efficient to store, quicker to search, and easier for the pupil to read. Abstraction is not removing data by accident — it is a deliberate modelling choice.
Large algorithms are typically decomposed into named sub-algorithms (procedures/functions). Consider a program that calculates the class average and highlights top performers:
FUNCTION average(marks)
total = 0
FOR i = 0 TO LENGTH(marks) - 1
total = total + marks[i]
NEXT i
RETURN total / LENGTH(marks)
ENDFUNCTION
FUNCTION topPerformers(marks, threshold)
result = []
FOR i = 0 TO LENGTH(marks) - 1
IF marks[i] >= threshold THEN
APPEND i TO result
ENDIF
NEXT i
RETURN result
ENDFUNCTION
marks = [72, 58, 90, 65, 81]
avg = average(marks)
OUTPUT "Average:", avg
OUTPUT "Top performers:", topPerformers(marks, 80)
Decomposition has two concrete benefits: the sub-algorithms are independently testable, and they are reusable — average could be applied to attendance figures, subject marks, or class sizes without modification. This is the core value of abstraction: once a procedure's interface is defined, callers need not know its internal workings.
Most non-trivial algorithms combine the three fundamental constructs:
| Construct | Pseudocode example | Purpose |
|---|---|---|
| Sequence | statement1; statement2 | Steps carried out one after another |
| Selection | IF / ELSE IF / ELSE | Choose a branch based on a condition |
| Iteration | FOR / WHILE / REPEAT | Repeat a block until a condition is met |
The register-taking algorithm above uses all three: sequence (the three output lines at the end), selection (the IF/ELSE IF chain that classifies each status), and iteration (the FOR loop over every pupil). Being able to identify these constructs in an unfamiliar algorithm is a frequent exam task.
The flowchart below (described in words) decides whether a mark awards a pass:
mark >= 40? — two arrows out.The flow of control is linear until the decision diamond, then rejoins. Every decision diamond must have exactly two exits.
| Representation | Strength | Weakness | Typical use |
|---|---|---|---|
| Natural language | Very easy to read | Ambiguous, wordy | Early planning, non-technical audience |
| Pseudocode | Precise, close to code | Requires conventions | Design stage before coding |
| Flowchart | Visual, shows control flow clearly | Hard to draw for long algorithms | Selection-heavy logic, teaching |
Common mistake: Candidates often give "a program" as a definition of an algorithm. A program is an implementation of an algorithm in a specific language — the algorithm itself is language-independent.
Exam-style question: Explain what is meant by an algorithm and describe two ways an algorithm may be represented. [4 marks]
Grades 3–4 response:
An algorithm is a set of steps to solve a problem. You can write it in English or draw a flowchart.
Grades 5–6 response:
An algorithm is a precise, step-by-step sequence of instructions that takes an input and produces an output. It can be written as pseudocode, which uses keywords like IF, WHILE and FOR, or drawn as a flowchart using symbols such as rectangles for processes and diamonds for decisions.
Grades 7–9 response:
An algorithm is a finite, unambiguous and effective sequence of steps that transforms a defined set of inputs into a defined output. Algorithms are language-independent and are implemented as programs. Two standard representations are pseudocode — a structured, language-agnostic notation that uses control-flow keywords (IF/THEN/ELSE, WHILE, FOR) and allows decomposition into named sub-procedures — and flowcharts, which depict control flow graphically using standardised shapes (terminator, process, decision, I/O). Both representations support abstraction by hiding implementation detail, enabling the designer to reason about correctness and complexity before committing to a programming language.
AQA alignment: This content is aligned with AQA GCSE Computer Science (8525) specification — specifically section 3.1 Fundamentals of algorithms (3.1.1 Representing algorithms, 3.1.2 Efficiency of algorithms, 3.1.3 Searching algorithms, 3.1.4 Sorting algorithms). Assessed on Paper 1 (Computational thinking and programming skills).