In simple terms
A friendly intro before the formal notes — no formulas yet.
The Recipe for Solving Problems
An algorithm is simply a precise, step-by-step set of instructions designed to perform a task or solve a problem. Think of it as the logical blueprint that tells a computer exactly what to do, from start to finish.
Imagine you're baking a cake. The recipe you follow is an algorithm. It lists the ingredients (inputs), provides a sequence of clear instructions to mix them (the process), and describes the final delicious cake (the output). If any step is vague or missing, you might not get the cake you expected; the same is true for computer algorithms.
- 1
Define the Problem: Clearly identify the inputs, the required processing, and the expected outputs.
- 2
Decompose into Steps: Break the overall problem down into smaller, more manageable sub-tasks.
- 3
Sequence and Structure: Arrange the steps logically using sequence, selection (IFs), and iteration (loops).
- 4
Refine and Test: Review the algorithm for clarity and correctness. Trace it with sample data to find any errors.
Explore the concept
Use the live diagram and synced steps — play it or tap a step card to walk through.
Sequence Statements run one after another, top to bottom; each assignment replaces the value a variable held before.
Full topic notes
Formal explanation with the rigour you need for the exam.
The Five Essential Properties of an Algorithm
For a set of instructions to be formally considered an algorithm, it must possess five key properties. When you're designing a solution for an exam question, mentally checking against these properties can help ensure your logic is sound.
Finiteness: The algorithm must eventually stop after a finite number of steps. An infinite loop, for example, violates this property.
Definiteness: Every step must be precisely and unambiguously defined. For example, 'Add 5 or 6' is ambiguous; 'Add 5' is definite.
Input: An algorithm takes zero or more inputs. These are the values on which the algorithm will operate.
Output: An algorithm produces at least one output. This is the result of the computation, the solution to the problem.
Effectiveness: Each instruction must be simple enough that it can be carried out in a finite amount of time. It must be practically possible to execute the step.
Representing Algorithms
In your A-Level course, you'll use two primary methods to describe and communicate algorithms: pseudocode and flowcharts. Pseudocode is a text-based description that uses English-like statements and programming conventions. Flowcharts are diagrammatic, using standard shapes to represent actions, decisions, and the flow of control. While you must be able to read and interpret both, exam questions will most often ask you to write your solutions in pseudocode.
Examiners are not testing your knowledge of a specific programming language like Python or Java. Your pseudocode should be clear, logical, and follow the standard conventions (e.g., DECLARE, INPUT, OUTPUT, IF...THEN...ELSE, ← or for assignment). As long as another programmer can understand your logic, you will get the marks.
Algorithm Design with Selection
Most algorithms are not just a simple sequence of steps. They need to make decisions based on the data they are processing. This is achieved using 'selection'. The most common selection structure is the IF...THEN...ELSE statement, which allows the algorithm to follow different paths depending on whether a condition is true or false.
Before finalising your algorithm, perform a quick 'dry run' or 'trace' with test data. For the cinema example, test with age 10 (discount), age 30 (full price), and age 70 (discount). Also test the boundary values: 15, 16, 64, and 65. This helps catch logical errors.
Worked examples
See the formulas applied — reveal one step at a time, like the exam.
An algorithm is required to calculate the area of a rectangle. It should take the length and width as inputs, calculate the area, and display the result. Write the algorithm in pseudocode.
- 1
Here is a step-by-step solution following standard pseudocode conventions.
A cinema offers discounted tickets to customers who are 15 years old or younger, or 65 years old or older. Write an algorithm in pseudocode that inputs a customer's age and outputs either 'Discount applies' or 'Full price payable'.
- 1
Identify inputs, processes, and outputs: * Input: Age * Process: Check if OR * Outputs: 'Discount applies' or 'Full price payable'
How it all connects
The big idea sits in the middle — tap a linked idea to explore the link.
Tap a linked idea to see how it connects back to the main topic — that connection is what examiners reward.
Glossary
Key terms for this topic — skim now; the Check step will test them.
- Finiteness
The algorithm must eventually stop after a finite number of steps.
- Definiteness
Every step must be precisely and unambiguously defined. For example, 'Add 5 or 6' is ambiguous; 'Add 5' is definite.
- Effectiveness
Each instruction must be simple enough that it can be carried out in a finite amount of time.
- Algorithm
A finite, ordered set of unambiguous, step-by-step instructions designed to solve a specific problem or perform a computation.
- 'Finiteness' property of an algorithm
An algorithm must always terminate after a finite number of steps. It cannot go on forever.
- 'Definiteness' property of an algorithm
Each step of an algorithm must be precisely and unambiguously defined. There should be no uncertainty in any instruction.
- 'Input' property of an algorithm
An algorithm has zero or more quantities that are externally supplied. These are the initial values needed to start the process.
- 'Output' property of an algorithm
An algorithm must produce at least one quantity as a result. This is the solution to the problem.
- 'Effectiveness' property of an algorithm
Every instruction must be basic enough to be carried out, in principle, by a person using only pencil and paper. It must be feasible.
- Pseudocode
A high-level, informal description of the operating principle of a computer program or other algorithm. It uses natural language with programming-like structures but is not tied to a specific language's syntax.
- Flowchart
A graphical representation of an algorithm, using standard symbols connected by arrows to show the sequence of operations and flow of control.
- Decomposition in algorithm design
The process of breaking down a complex problem into smaller, more manageable, and self-contained sub-problems. This simplifies the design process.
Quick check
Write your answer first, then compare it with the model one — the gap is what you would have lost.
Teach it back
If you can explain it simply, you own it — gaps here are marks you’d lose.
Teach it back
Explain this topic as if teaching a friend. We name the gaps an examiner would still dock.
Revision flashcards
Guess first, then flip — retrieval beats re-reading.
Key takeaways
Review these before you close the topic — retrieval beats re-reading.
Finiteness: The algorithm must eventually stop after a finite number of steps. An infinite loop, for example, violates this property.
Definiteness: Every step must be precisely and unambiguously defined. For example, 'Add 5 or 6' is ambiguous; 'Add 5' is definite.
Input: An algorithm takes zero or more inputs. These are the values on which the algorithm will operate.
Output: An algorithm produces at least one output. This is the result of the computation, the solution to the problem.
Effectiveness: Each instruction must be simple enough that it can be carried out in a finite amount of time. It must be practically possible to execute the step.
Practice — then mark it
The whole point: a real Cambridge question, marked mark-by-mark.
A program includes the following assignment statement: Result STR_TO_NUM() / STR_TO_NUM() When the program evaluates the expression in the statement, it performs a calculation. Variable Result is of type real and variables and are of type string. Two checks are required before the calculation is performed:
- The two strings represent valid numeric values.
- The numeric value of string is not zero.
Identify the type of error that could occur if these checks are not carried out and state a cause of this error. Type Cause
(b) The designer considers implementing the checks and calculation as a module (a procedure or a function). One reason for this is that the same checks and calculations are performed at several places in the program. Give another reason why this is a suitable approach and state what is avoided by this approach. Reason Avoided
(c) The module to perform the checks and calculation will be implemented as a function. The function will need to return both a real and a Boolean value. To achieve this a record type is defined in pseudocode as follows: TYPE Result DECLARE Done : BOOLEAN DECLARE Value : REAL ENDTYPE The function Evaluate() will:
- take two parameters of type string representing the two numeric values
- return a variable of type Result with the Done field set to FALSE if either of the following applies:
- at least one of the strings does not represent a valid numeric value
- the numeric value of the string representing value is zero
- otherwise return a variable of type Result with the Done field set to TRUE and the Value field assigned the result of the formula (based on the numeric value of the two parameters).
Write pseudocode for the function Evaluate().
Extra simulations & links
PhET, GeoGebra and other curated tools — open in a new tab.
Frequently asked
Checkpoint
One marked question is worth ten re-reads — close the loop before you move on.
Reading it isn’t knowing it — prove it.
Before you move on: do 9618/21 · Q4 on paper, snap a photo, and get examiner-style feedback on exactly where you win and lose marks.
Discuss Algorithms
Ask, share and discuss with other Computer Science students