Big-O Reference

Complexity Cheat Sheet

Time and space complexity for all 31 algorithms, filterable by category.

Algorithm
Category
Best
Average
Worst
Space
Tags
Bubble SortsortingO(n²)O(n²)O(n²)O(1)
comparisonin-placestable
Selection SortsortingO(n²)O(n²)O(n²)O(1)
comparisonin-placeunstable
Insertion SortsortingO(n)O(n²)O(n²)O(1)
comparisonin-placestable
Merge SortsortingO(n log n)O(n log n)O(n log n)O(n)
divide-and-conquerstablenot-in-place
Quick SortsortingO(n log n)O(n log n)O(n²)O(log n)
divide-and-conquerin-placeunstable
Heap SortsortingO(n log n)O(n log n)O(n log n)O(1)
comparisonin-placeunstable
Counting SortsortingO(n+k)O(n+k)O(n+k)O(k)
non-comparisonstableinteger-sort
Radix SortsortingO(d·n)O(d·n)O(d·n)O(n+k)
non-comparisonstableinteger-sort
Shell SortsortingO(n log n)O(n^1.5)O(n²)O(1)
comparisonin-placeunstable
Linear SearchsearchingO(1)O(n)O(n)O(1)
simpleunsorted
Binary SearchsearchingO(1)O(log n)O(log n)O(1)
sorteddivide-and-conquerefficient
Breadth-First SearchsearchingO(V+E)O(V+E)O(V+E)O(V)
graphlevel-ordershortest-path
Depth-First SearchsearchingO(V+E)O(V+E)O(V+E)O(V)
graphrecursivebacktracking
B-TreeDSO(log n)O(log n)O(log n)O(n)
treebalancedmultiway
B+ TreeDSO(log n)O(log n)O(log n)O(n)
treebalancedmultiway
B* TreeDSO(log n)O(log n)O(log n)O(n)
treebalancedmultiway
Extensible HashingDSO(1)O(1)O(n)O(n)
hashdynamicdirectory
Array OperationsDSO(1)O(n)O(n)O(1)
fundamentalrandom-access
Singly Linked ListDSO(1)O(n)O(n)O(n)
dynamicsequentialpointer
Doubly Linked ListDSO(1)O(n)O(n)O(n)
dynamicsequentialpointer
StackDSO(1)O(1)O(1)O(n)
LIFOsequentialrecursive
QueueDSO(1)O(1)O(1)O(n)
FIFOsequentialscheduling
Binary Tree TraversalsDSO(n)O(n)O(n)O(h)
treehierarchicaltraversal
Binary Search TreeDSO(log n)O(log n)O(n)O(n)
treehierarchicalordered
Hash TableDSO(1)O(1)O(n)O(n)
hashkey-valueO(1)-lookup
Min-HeapDSO(1)O(log n)O(log n)O(n)
heappriority-queuecomplete-tree
FibonacciDPO(n)O(n)O(n)O(n)
memoizationtabulationoverlapping-subproblems
0/1 KnapsackDPO(n·W)O(n·W)O(n·W)O(n·W)
optimizationsubset-selectionclassic
Longest Common SubsequenceDPO(m·n)O(m·n)O(m·n)O(m·n)
stringsubsequencediff
Longest Increasing SubsequenceDPO(n²)O(n²)O(n²)O(n)
subsequencepatience-sortordering
Coin ChangeDPO(amount·n)O(amount·n)O(amount·n)O(amount)
optimizationminimum-coinsunbounded
Big-O Notation Guide

Interactive growth curves, complexity cards, and algorithm examples — all in one place.

→ Open Guide
Click any algorithm name to open its interactive visualizer.