How to use Big-O notation
Big-O describes how runtime grows with input size. Learn to recognise O(1), O(log n), O(n), and O(n²) in common algorithms.
Big-O notation answers one question: how does the runtime grow as the input size n grows?
Common classes
| Class | Meaning | Example | |---|---|---| | | Constant time | Array lookup by index | | | Halves each step | Binary search | | | One pass | Linear search | | | Nested passes | Bubble sort |
How to spot it
- A single loop over n items → .
- Nested loops, each over n → .
- Halving the search space each step → .
Big-O ignores constants: is still . Practise on randomised complexity questions below.
Put it into practice
Practise this topic with questions and get an explanation after each answer.
Practice this now →