Cambridge O Level Computer Science · Syllabus 2210 · Algorithm Design and Problem-Solving
Algorithm
What is Algorithm?
A finite, ordered and unambiguous sequence of steps that solves a problem or completes a task; it is a logical solution independent of any programming language, and it may be recorded as a structure diagram, a flowchart or pseudocode.
This definition is part of the Algorithm Design and Problem-Solving chapter in Cambridge O Level Computer Science.
Algorithm in context
Paper 2, Algorithms, Programming and Logic, is a written paper of 1 hour 45 minutes carrying 75 marks. It is set on Topics 7 to 10. All questions are compulsory and you answer on the question paper. Calculators are not allowed. The questions expect you to have real practical programming experience, but knowledge of programming-language syntax is not examined — in all cases the logic is more important than the syntax.
An algorithm is a finite, ordered and unambiguous sequence of steps that solves a problem or completes a task. Finite means it stops. Ordered means the steps happen in a stated sequence. Unambiguous means every step has exactly one meaning — a reader cannot choose between two interpretations. An algorithm is a logical solution: it is not tied to any programming language, and it exists before any code is written.
A flowchart is a diagram that shows the order in which the steps of an algorithm are carried out, using a fixed set of symbols joined by flow lines with arrowheads. Section 4 of the syllabus defines exactly six symbols, and each has one meaning. Using the wrong shape is not a presentation slip — it changes what the diagram claims.
Pseudocode is a way of writing an algorithm that uses the structure of a program — assignment, selection, iteration, input and output — without belonging to any programming language. Section 4 of the syllabus sets out exactly how it appears in examinations. Because Paper 2 marks logic rather than syntax, a small slip is survivable; what is not survivable is ambiguity, and the conventions below exist to remove it.
The syllabus asks for two things: stating the purpose of an algorithm and describing the processes involved in it. A purpose statement answers “what problem does this solve?” in terms of what goes in and what comes out. A process description answers “how?” by naming the standard methods and conditions used. An answer that only lists statements in order has described the code, not its purpose.
A dry run is following an algorithm by hand, one executed statement at a time, exactly as a computer would. A trace table is the record of that dry run: a column for each variable of interest, plus columns for conditions, outputs and user prompts as required, and a row for each step. The whole value of the technique comes from one discipline: you write down what the algorithm does, not what you think it is supposed to do.
Finding an error is a four-step job, and questions are marked on all four: identify the faulty line or component, explain the consequence for the algorithm’s behaviour, correct it precisely (write the replacement line, not a description of it), and retest with data that would have exposed the fault. Almost all the errors in Topic 7 are logic errors: the algorithm runs perfectly and produces the wrong answer.
Every algorithm you write in Topic 7 is built from the same small kit: sequence, selection, repetition, and the seven standard methods. The route to a long answer is not more cleverness — it is doing the short ones so reliably that they can be stacked. The ladder below runs from a three-line sequence to a combined scenario, and every model answer has been executed by hand and checked.
This mixes every kind of demand Topic 7 makes: definitions, ordering a process, reading a flowchart, tracing an algorithm, choosing a standard method, classifying test data and diagnosing a defect. Answer all fifteen before checking anything. Every question explains why the right answer is right, so a wrong answer is worth more than a lucky one.
Common mistakes with Algorithm
- M6. “An algorithm has to be written in a programming language.” Correct An algorithm is a finite, ordered, unambiguous sequence of steps. It can be a flowchart, pseudocode, a structure diagram or ordinary written steps.
- M21. “A dry run means working out what the final answer should be, and a trace table records only the final values.” Correct A dry run follows the algorithm one executed statement at a time, and a trace table records every change, every condition result, every prompt and every output along the way. Why it matters Trace-table questions almost always use a defective algorithm. Writing down the answer you expected is exactly how the fault is missed.
Examiner tips on Algorithm
- Which one will the exam ask for? Read the command. “Draw a flowchart” means shapes and arrows. “Write an algorithm”, “write pseudocode” or “complete the pseudocode” means Cambridge pseudocode. “Complete the structure diagram” means fill in boxes in a hierarchy. Answering in the wrong notation is one of the few ways to write a completely correct solution and score zero.
- Four columns, every time. A test-data answer that scores fully gives the value, the category, the expected outcome and the reason. Writing “10, 11, 16, 17” on its own gives a marker four numbers and no evidence that you know why they were chosen. Writing “17 — boundary — rejected — the smallest value above the upper limit, so it proves the algorithm uses <= and not <” gives them everything.
- “It is a syntax error” is almost never the answer. The algorithms set in this topic are logically defective, not unwritable. Marks come from saying what the algorithm does wrong: “the total is reset each time, so only the last score is added” earns; “there is a mistake on line 2” does not. If you can state the wrong output that the fault produces, you have the explanation mark.
- The six-point check before you write anything. (1) What are the inputs, and how many? (2) What is the output, and is it one value or several? (3) Do I need to repeat something, and is the number of repetitions known in advance? (4) Does anything need initialising before the loop? (5) Does anything need to happen only after the loop? (6) What must the algorithm do with data it should not accept? Answer those six and the structure of the algorithm is already decided.
Questions students ask about Algorithm
What is the difference between a dry run and testing?
A dry run is done by hand, on paper, following the algorithm statement by statement — usually recorded in a trace table. Testing runs the actual program on a computer with chosen test data. A dry run finds logic faults before any code exists, which is exactly why it belongs to the design stage as well as to debugging.
If a bubble sort finishes sorting the data on pass 2, why does it do a pass 3?
Because the algorithm has no way of knowing the data is sorted except by making a complete pass with no swaps. Pass 3 makes the comparisons, finds nothing to swap, leaves the flag TRUE, and the loop ends. In an exam answer, showing that final quiet pass is part of showing that you understand the stopping rule.
How many marks is an algorithm question usually worth, and how much should I write?
Roughly one marking point per mark, and the points are usually structural: initialisation, the loop with the right bounds, the condition, the update, the output in the right place, and the handling of invalid or not-found cases. Before writing, count the marks and list that many structural features — it is a far more reliable guide to length than the size of the answer space.
Is “the program crashed” ever the right description of a logic error?
Rarely. Almost every defect in this topic is one where the algorithm runs happily and produces a wrong answer: a total short by one item, an average divided by the wrong number, a maximum of zero. When you describe an error, name the wrong output it produces. That sentence is usually where the explanation mark lives.
What is the single most useful habit for Topic 7?
Trace your own algorithm with two values before you move on: the first item and the last item. Nearly every off-by-one error, wrong loop bound, misplaced initialisation and misplaced output shows up in one of those two iterations, and finding it yourself takes about forty seconds.

