# Time Complexity

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

**Field:** Software Development  
**Category:** Algorithms & Data Structures  
**Also known as:** Running Time, Runtime Complexity

## Think of it like

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

## 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).

## 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.

## Common mistake

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

## Three principles

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

## Related terms

- [Big O Notation](https://learn.benibix.com/term/development/big-o-notation)
- [Space Complexity](https://learn.benibix.com/term/development/space-complexity)
- [Algorithm](https://learn.benibix.com/term/development/algorithm)
- [Loop](https://learn.benibix.com/term/development/loop)
- [Best, Worst and Average Case](https://learn.benibix.com/term/development/best-worst-average-case)

## Told apart from

- [Time vs Space Complexity](https://learn.benibix.com/compare/time-vs-space-complexity): Time complexity counts steps. Space complexity counts memory. Both say how the cost grows as the input grows, and a faster way often needs more memory.

---

Source: https://learn.benibix.com/term/development/time-complexity
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
