Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).

Knowledge/A Level/H446/02 Algorithms and programming/Algorithms/Comparison of the complexity of algorithms

Comparison of the complexity of algorithms

Comparison of the complexity of algorithms.

2.3.1 Algorithms

Practise exam questions

Algorithms — Note 4 of 6

Candidates need to know the best and worst case complexities for the searching and sorting algorithms. Candidates need to understand the difference between best, average and worst case complexity and why these can differ for an algorithm.

What you need to know

You need to compare the standard searching and sorting algorithms using Big O notation, including their best, average and worst cases, and explain why these can differ.

What to know

  • Linear search: best O(1), average and worst O(n). Binary search: best O(1), average and worst O(log n).
  • Bubble sort: best O(n) (already sorted, with a flag to stop when no swaps are made), average and worst O(n²).
  • Insertion sort: best O(n) (already sorted), average and worst O(n²).
  • Merge sort: O(n log n) in every case, but needs O(n) extra space.
  • Merge sort does not win every case: insertion sort, and bubble sort with a swap flag, are O(n) on already sorted data, while merge sort stays O(n log n).
  • Quick sort: best and average O(n log n), worst O(n²) (when the pivot is repeatedly the smallest or largest item).
  • Binary search tree search: average O(log n), worst O(n) if the tree is unbalanced.
  • The same Big O does not mean the same speed: insertion and bubble sort are both O(n²), but insertion sort usually makes fewer comparisons. For a small n, constant factors can matter more than the growth rate.

Code examples

Summary of time complexities
text
Algorithm        Best         Average      Worst        Extra space
Linear search    O(1)         O(n)         O(n)         O(1)
Binary search    O(1)         O(log n)     O(log n)     O(1)
Bubble sort      O(n)         O(n^2)       O(n^2)       O(1)
Insertion sort   O(n)         O(n^2)       O(n^2)       O(1)
Merge sort       O(n log n)   O(n log n)   O(n log n)   O(n)
Quick sort       O(n log n)   O(n log n)   O(n^2)       O(log n)*

Binary search's O(1) space is for the iterative version; a recursive
version uses O(log n) space for its call stack.

* Quick sort uses O(log n) space on average, up to O(n) in the worst case.

Key terms

Best case

The input that makes the algorithm do the least work, e.g. the item being searched for is first in the list.

Worst case

The input that makes the algorithm do the most work, e.g. the item is last or not present.

Average case

The expected work over typical inputs.

Exam technique

  • Tip:Worst-case complexity is usually the most important when guaranteeing performance.
  • Tip:When you compare, say which case (best, average or worst) and which resource (time or space) each Big O refers to, and apply it to the size of the data in the question. 'Faster' on its own earns little.

Ready to test yourself?

Practise 2.3.1 questions
← Previous noteMeasures and methods to determine efficiency, Big O notation2.3.1 AlgorithmsNext note →Algorithms for stacks, queues, trees, linked lists, depth-first (post-order) and breadth-first traversal2.3.1 Algorithms

Back to Algorithms

Algorithms

Note 4 of 6

  1. 1Analysis and design of algorithms for a given situation
  2. 2The suitability of different algorithms for a given task and data set, in terms of execution time and space
  3. 3Measures and methods to determine efficiency, Big O notation
  4. 4Comparison of the complexity of algorithms
  5. 5Algorithms for stacks, queues, trees, linked lists, depth-first (post-order) and breadth-first traversal
  6. 6Standard algorithms: sorts, Dijkstra's shortest path, A*, binary search and linear search
Topic overview