Skip to content
BENIBIX Learn

Time Complexity

Development🧮 Algorithms & Data StructuresAlgorithm Basics

Also known as Running Time, Runtime Complexity

How much more work as the input grows. It is written in Big O.

Think of it like

Think of it like a walk. You count the steps, not the minutes.

Example

Emma's loop inside a loop checks every pair of 1,000 users. That is O(n²), about 1,000,000 checks.

Why it matters

It tells you whether code that runs fine on 100 rows will still run on 10 million.

Definition

Time complexity is how the number of steps an algorithm takes grows with the size of its input. It is written in Big O, like O(n) or O(n log n). It counts steps rather than seconds, so it does not depend on how fast the computer is. Looking up a key in a hash table is O(1) on average. Sorting with merge sort is O(n log n).

Common mistake

Timing code once with a stopwatch and calling that its complexity. Time it at several sizes to see the shape.

Key takeaways

  1. 1
    Steps, not seconds. The machine does not matter.
  2. 2
    Written in Big O. O(1), O(n), O(n log n).
  3. 3
    Grows with input. That is the point.

Compare