Reqflow
Interactive

Time Complexity Sandbox

Drag the slider to change n and watch how each complexity class grows. O(n²) gets expensive fast — O(log n) barely moves. This is why algorithm choice matters.

1.00101001.0K10.0K0100200300400500n (input size)operations (log scale)n = 50
n = 50500
ComplexityOperations at n = 50ExamplesRating
O(1)1.00Hash lookup, array accessExcellent
O(log n)5.64Binary search, BST opsExcellent
O(n)50Linear scan, sliding windowGood
O(n log n)282Merge sort, quick sortGood
O(n²)2.5KBubble, selection, insertion sortAcceptable
At n = 50: O(n²) is 9× more work than O(n log n). For small n this is fine.

What these mean in practice

O(1)
ConstantHash map lookup, array index access. Does not matter how big the input is.
O(log n)
LogarithmicBinary search, balanced BST ops. A million elements takes about 20 steps.
O(n)
LinearLinear scan, single-pass algorithms. Double the input → double the work.
O(n log n)
Log-linearMerge sort, quick sort (avg). The best possible comparison-based sort.
O(n²)
QuadraticBubble, selection, insertion sort. Fine for n < 1000, painful beyond that.
← All algorithmsCheat sheetTake the quiz