Sciomi uses Google Analytics to measure how the site is used. If you accept, it stores a cookie on your device. If you decline, it stores nothing on your device, but Google may still receive a basic signal that a page was opened. Sign-in and practice progress cookies are always used. No ads are shown. Details in the privacy policy

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 | |---|---|---| | O(1)O(1) | Constant time | Array lookup by index | | O(log⁡n)O(\log n) | Halves each step | Binary search | | O(n)O(n) | One pass | Linear search | | O(n2)O(n^2) | Nested passes | Bubble sort |

How to spot it

  • A single loop over n items → O(n)O(n).
  • Nested loops, each over n → O(n2)O(n^2).
  • Halving the search space each step → O(log⁡n)O(\log n).

Big-O ignores constants: 2n+32n + 3 is still O(n)O(n). 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 →