Skip to content
BENIBIX Learn

Big O Notation

Development🧮 Algorithms & Data StructuresAlgorithm Basics

Also known as Big O, Big-O, O(n), Asymptotic Notation

How fast an algorithm's work grows when its input grows.

Think of it like

Think of it like a walk. If the road gets twice as long, how much longer is the walk?

Example

Lucy's search checks every name, which is O(n). For 1,000,000 names it may take 1,000,000 checks; a binary search needs about 20.

Why it matters

It lets you compare algorithms before you write them. A bad growth shape hurts more as data gets bigger.

Definition

Big O notation describes how the work an algorithm does grows as its input grows. O(1) means the work stays the same, however big the input. O(n) means the work grows in step with the input. O(n²) means doubling the input makes four times the work. It ignores small details and shows the shape of the growth.

Common mistake

Reading Big O as an exact speed. It only says how the work grows; a slow O(n) can beat a fast O(n²) on tiny inputs.

Key takeaways

  1. 1
    Growth, not speed. How work rises with size.
  2. 2
    Common shapes. O(1), O(log n), O(n), O(n²).
  3. 3
    Worst case usually. Unless it says otherwise.