A-Level · Algorithms

Big O and Algorithmic Complexity

Every algorithm built across this course so far has a Big O rating, binary search is O(log n), naive Fibonacci is O(2ⁿ), bubble sort is O(n²). This page makes precise what those labels actually mean, using nothing but real, verified numbers already produced by those exact algorithms.

Section 1

What Big O actually measures

Big O describes how the amount of work grows as the input size (n) grows, not the exact number of operations, and almost always the worst case.

Section 2

The complexity ladder, drawn from real data

Every curve below comes from an algorithm already built and verified elsewhere on this site, not an abstract formula. Toggle which ones are visible and watch how dramatically they separate as n grows.

n (input size) shown

1 30

n = 20

Preset views

Section 3

Every algorithm on this site, classified

These aren't hypothetical examples. Every single row below is something you've already run, stepped through, and watched execute elsewhere in this course.

AlgorithmClassWhere you've seen it
Array index accessO(1)Constant time, regardless of array size
Binary searchO(log n)Searching Algorithms lesson, halves the search space every step
Linear searchO(n)Searching Algorithms lesson, worst case checks every element
Merge sortO(n log n)Sorting Algorithms lesson, barely changes between best and worst case
Quicksort (typical)O(n log n)Sorting Algorithms lesson, but see the exam tip below
Bubble sort / Insertion sortO(n²)Sorting Algorithms lesson, nested comparisons
Quicksort (worst case)O(n²)Genuinely happens on already-sorted input with a naive pivot, see the sorting lesson
Naive recursive FibonacciO(2ⁿ)Recursion Fundamentals lesson, verified 2,692,537 calls for fib(30)

Quicksort is deliberately listed twice: its typical performance is excellent, O(n log n), but with a naive pivot choice (always the last element), an already-sorted list is its actual worst case, O(n²), the opposite pattern from every other sort here. Same algorithm, two different classes, depending entirely on the input.

Section 4

Formal notation: dropping constants and lower-order terms

"Just drop the small stuff" sounds like a shortcut. Here's the actual reasoning, worked through with real numbers, not just asserted.

f(n) = 3n² + 5n + 2
As n grows, the n² term completely dominates the others, by n=1000, it accounts for over 99.8% of the total. The 5n and +2 terms become utterly irrelevant to the growth shape, which is exactly why f(n) = 3n² + 5n + 2 is simply written O(n²). The constant 3 gets dropped too, since it doesn't change which class the function belongs to, only OCR/AQA mark schemes generally just want the dominant term's shape identified.
Section 5

Classify it yourself

Four short pseudocode snippets. Work out each one's Big O before revealing the answer, verified against real operation counts, not just claimed.

Section 6

Check your understanding