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
More than one answer
Understand that more than one algorithm can be used to solve the same problem. Adding two numbers, finding the largest value in a list, searching for a name — each of these has several valid approaches. The question is never 'is this algorithm correct' but 'is this the most efficient way of doing this particular job'.
Key fact: More than one algorithm can solve the same problem, so the comparison is about efficiency.
What efficiency means here
Compare the efficiency of algorithms, explaining how some algorithms are more efficient than others in solving the same problem. Formal comparisons of algorithmic efficiency are not required, and exam questions in this area will only refer to time efficiency. So you are not expected to use Big-O notation; you are expected to count operations or count steps and compare.
Key fact: Efficiency here means time efficiency only — no formal notation is required.
How to compare two algorithms
The method is to count the work. Trace both algorithms on the same input and count the number of steps each one takes. If the input is a list of 100 items and one algorithm makes 100 comparisons while the other makes 7, the second is more efficient on that input. The more careful answer also notes that efficiency can depend on the input: an algorithm that is usually slow can still win on a particular case.
Key fact: Count the steps of each algorithm on the same input and compare.
How the answer is judged
A comparison answer needs three things: the two algorithms named, the number of steps or comparisons each one takes, and a statement of which is more efficient and why. Missing the third is what loses the marks. And because only time efficiency is examined, do not write about memory or cost unless the question asks.
Key fact: Name both algorithms, count the steps for each, and state which is more efficient.
Comparing a search and a sort
The classic case is linear search against binary search, and merge sort against bubble sort, both covered in the next two sections. The point to hold on to is that efficiency is always relative to a task and an input size. Binary search halves the list each step but needs a sorted list; a merge sort is efficient on huge lists but uses extra memory.
Key fact: Efficiency depends on the task and the size and type of the input.
Growth, not just numbers
Even though you will not be examined on formal notation, you can say in words that one algorithm takes roughly twice as long as the list gets twice as long, while another takes much longer. That is the idea behind growth rates, and it is enough for full marks as long as you back it up with counts from a trace table.
Key fact: Describe how the work changes as the input grows, supported by counts.
Flashcards
What kind of efficiency do exam questions in this area refer to?
Time efficiency only.
Is formal algorithmic efficiency notation required?
No, formal comparisons of algorithmic efficiency are not required.
How do you compare two algorithms in an exam?
Trace both on the same input and count the number of steps or comparisons each one takes.
Why might two algorithms with different efficiency be the right choice on different inputs?
Because efficiency depends on the size and type of the input, so an algorithm that is usually slower can still win on a particular case.
What three things does a comparison answer need?
The two algorithms named, the number of steps or comparisons each takes, and a statement of which is more efficient and why.
Name two pairs of algorithms that can be compared in this specification.
Linear search against binary search, and merge sort against bubble sort.
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
An exam asks you to compare two sorting algorithms. Which of these is the question expecting you to do?
Write the Big-O notation for each algorithm
Explain which algorithm uses less memory
Count the steps each algorithm takes on the same input
Give the source code of both algorithms
Mark scheme: 1 mark for identifying that the comparison is made by counting steps. Formal comparisons of algorithmic efficiency are not required and exam questions in this area only refer to time efficiency.
short3 marks
Explain in English how you would write an answer comparing the efficiency of two algorithms, and what you must include for full marks.
Mark scheme: 1 mark for explaining that you trace both algorithms on the same input and count the steps or comparisons each takes. 1 mark for naming the two algorithms and giving the counts. 1 mark for stating which is more efficient and why, and noting that the answer should refer to time efficiency.
six6 marks
Explain in English what it means for one algorithm to be more efficient than another, and why the input matters.
Mark scheme: Level 1 (1-2 marks): A short answer saying one algorithm takes fewer steps to do the same job. Level 2 (3-4 marks): A structured answer covering the method of counting steps and what a full comparison answer needs. Level 3 (5-6 marks): A detailed answer explaining that efficiency is about time and that more than one algorithm can solve the same problem, describing how a trace table gives the counts for each algorithm on the same input, explaining that the answer must name the algorithms, give the counts and conclude, and explaining that efficiency depends on the size and type of the input so a generally slower algorithm can still be the better choice on a particular case.