Skip to main content
EnglandComputer ScienceSyllabus dot point

How do we measure and compare the efficiency of algorithms using Big-O notation?

Big-O notation for time and space complexity: the constant, logarithmic, linear, linearithmic, polynomial and exponential complexity classes, how to determine the Big-O of an algorithm, and using it to compare and judge the suitability of algorithms.

An OCR H446 answer on Big-O notation: the constant, logarithmic, linear, linearithmic, polynomial and exponential complexity classes for time and space, how to determine an algorithm's Big-O, and using it to compare algorithms and judge their suitability.

Generated by Claude Opus 4.814 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

OCR wants the meaning of Big-O for time and space, the standard complexity classes in order, how to determine an algorithm's Big-O (from loops and recursion), and how to use Big-O to compare algorithms and judge suitability. This is analysis: expect to order classes, give examples, and determine the complexity of a code fragment.

The answer

What Big-O measures

Why constants and lower-order terms are dropped

The complexity classes and determining Big-O

Examples in context

Choosing binary search (O(logn)O(\log n)) over linear search (O(n)O(n)) is the difference between 20 and a million comparisons on a million items. Quadratic sorts become unusable on large datasets, so libraries use O(nlogn)O(n \log n) sorts. Exponential algorithms (naive travelling salesman) are why heuristics exist. Database query planners reason about complexity to pick efficient strategies. OCR ties Big-O to the searching, sorting and graph algorithms (each labelled with its complexity) and to the computational methods that tame intractable problems.

Try this

Q1. State what Big-O notation describes. [1 mark]

  • Cue. How an algorithm's running time (or space) grows as the input size nn grows (its worst-case order of growth).

Q2. Give the time complexity of an algorithm with a single loop running nn times, and one with two such loops nested. [2 marks]

  • Cue. Single loop O(n)O(n); nested loops O(n2)O(n^2).

Q3. Order O(n)O(n), O(1)O(1), O(n2)O(n^2) and O(logn)O(\log n) from most to least efficient. [1 mark]

  • Cue. O(1)O(1), O(logn)O(\log n), O(n)O(n), O(n2)O(n^2).

Exam-style practice questions

Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

OCR 20206 marksOrder the complexity classes O(1)O(1), O(n2)O(n^2), O(logn)O(\log n), O(n)O(n) and O(2n)O(2^n) from most to least efficient for large nn, and give an example algorithm for three of them.
Show worked answer →

Ordering (up to 3), most efficient first: O(1)O(1), O(logn)O(\log n), O(n)O(n), O(n2)O(n^2), O(2n)O(2^n). (Constant beats logarithmic beats linear beats quadratic beats exponential.)

Examples (up to 3), any three: O(1)O(1) accessing an array element by index; O(logn)O(\log n) binary search; O(n)O(n) linear search; O(n2)O(n^2) bubble or insertion sort; O(2n)O(2^n) a naive recursive solution to the subset/travelling-salesman-style problem. Markers reward the correct efficiency order and valid example algorithms. A common error is ranking O(n2)O(n^2) as better than O(2n)O(2^n) incorrectly, or vice versa; exponential is the worst.

OCR 20226 marksExplain what Big-O notation describes, why constants and lower-order terms are dropped, and determine the time complexity of an algorithm that contains a single loop nested inside another loop, each running nn times.
Show worked answer →

What Big-O describes (up to 2): Big-O describes how an algorithm's running time (or space) grows as the size of the input nn grows, giving the worst-case order of growth so algorithms can be compared independently of hardware.

Dropping constants and lower-order terms (up to 2): for large nn the fastest-growing term dominates, so constant factors and lower-order terms become insignificant; 3n2+5n+23n^2 + 5n + 2 is written O(n2)O(n^2) because the n2n^2 term dominates. This captures scalability, not exact timings.

Nested loops (up to 2): a loop running nn times with another loop running nn times inside it performs about n×n=n2n \times n = n^2 operations, so the time complexity is O(n2)O(n^2). Markers reward growth-with-input-size, dominance of the highest-order term, and O(n2)O(n^2) for the nested loops.

Related dot points

Sources & how we know this