Computer Science
Intermediate

Common Time Complexities

Ordering of common algorithmic growth rates.

Formula

O(1)<O(logn)<O(n)<O(nlogn)<O(n2)<O(2n)O(1) < O(\log n) < O(n) < O(n\log n) < O(n^2) < O(2^n)

Variables

nInput size

Example

For large n, an O(n log n) sort crushes an O(n²) one — e.g. millions vs trillions of steps.

Did You Know?

An O(n²) algorithm on a million items does a trillion operations — why algorithm choice matters enormously.