OCR A-level Big O notation: what is the time complexity?
Question 1 of 8
Pick an answer
Your result
A-level Computer Science Pro
Get an A or your money back
£119 once
Price rises to £199 on 1 January. Save £80 by joining before then.
No VAT is charged. Conditions
The OCR A-level Big O notation drill has 8 practice questions, each with a worked answer.
Questions people ask
How do you work out Big O from code?
Find the line that runs most often and count its runs in terms of n. One loop is O(n), a loop inside a loop is O(n²), halving each time is O(log n).
Why is two loops one after another O(n)?
n + n = 2n steps, and Big O drops constant multiples, so it is O(n). Only a loop inside a loop multiplies.
What Big O does OCR expect you to know?
Constant O(1), logarithmic O(log n), linear O(n), polynomial such as O(n²), and exponential O(2ⁿ), plus the complexities of the standard searching and sorting algorithms.
More free tools
How we work this out
What it does
Read the code, pick its Big O, and see how to count the steps.
OCR A Level Computer Science (H446) 2.3.1: Big O time complexity of code fragments.
Method
- Count how many times the innermost line runs as n grows, then keep the fastest-growing term and drop constants.
- Each wrong choice is a common slip: one loop counted as two, a halving loop counted as linear, or a constant left in.