EN
My tools

Big O Cheat Sheet (with Run-Time Estimator)

Big O time and space complexity of arrays, hash tables, trees, heaps, sorting and graph algorithms, plus a growth table and a run-time estimate for your n.

About 10⁸ is a common rule of thumb for compiled code; interpreted languages are often 10–100 times slower.
Operations
1,660,964
O(n log n) at n = 100,000 (log base 2)
Estimated time
16.6 ms
at 100,000,000 operations per second
Seconds
0.01661

Big O ignores constant factors: an O(n log n) algorithm with a large constant can be slower than an O(n²) one for small n. The estimate assumes one simple operation per counted step.

Time at n = 100,000 for each complexity
ComplexityOperationsTime
O(1)1< 1 µs
O(log n)16.61< 1 µs
O(√n)3163.2 µs
O(n)100,0001 ms
O(n log n)1,660,96416.6 ms
O(n²)10,000,000,000100 s
O(n³)1.00 × 10^15115.7 days
O(2ⁿ)9.99 × 10^30,1023.17 × 10^30,087 years
O(n!)2.82 × 10^456,5738.95 × 10^456,557 years
Data structures — time per operation and space
StructureAccessSearchInsertDeleteSpaceNote
Array (static)O(1)O(n)O(n)O(n)O(n)Insert/delete shift the elements after the position.
Dynamic array (vector, ArrayList, list)O(1)O(n)O(1) amortized at the end · O(n) elsewhereO(1) at the end · O(n) elsewhereO(n)A resize copies everything (O(n)) but happens rarely.
Singly linked listO(n)O(n)O(1) at the head or after a known nodeO(1) at the head · O(n) to find the nodeO(n)
Doubly linked listO(n)O(n)O(1) at either end or a known nodeO(1) at a known nodeO(n)
Stack / queue / dequeO(n)O(n)O(1) push / enqueueO(1) pop / dequeueO(n)Only the ends are accessible in O(1).
Hash table (hash map, set)—O(1) average · O(n) worstO(1) average · O(n) worstO(1) average · O(n) worstO(n)Worst case when many keys collide; no ordering.
Binary search tree (unbalanced)O(log n) average · O(n) worstO(log n) average · O(n) worstO(log n) average · O(n) worstO(log n) average · O(n) worstO(n)Sorted input degrades it to a linked list.
AVL tree / red-black treeO(log n)O(log n)O(log n)O(log n)O(n)Worst case guaranteed by rebalancing (TreeMap, std::map).
B-tree / B+ treeO(log n)O(log n)O(log n)O(log n)O(n)Few, wide levels — used by databases and file systems.
Binary heap (priority queue)O(1) min/max onlyO(n)O(log n)O(log n) extract-minO(n)Building a heap from n items is O(n).
Trie (prefix tree)—O(m)O(m)O(m)O(total key length)m = length of the key, independent of n.
Skip listO(log n) averageO(log n) average · O(n) worstO(log n) average · O(n) worstO(log n) average · O(n) worstO(n) expected
Disjoint set (union-find)—O(α(n)) findO(α(n)) union—O(n)With path compression and union by rank; α grows slower than log.
Sorting algorithms
AlgorithmBestAverageWorstExtra spaceStable
QuicksortO(n log n)O(n log n)O(n²)O(log n)No
Merge sortO(n log n)O(n log n)O(n log n)O(n)Yes
HeapsortO(n log n)O(n log n)O(n log n)O(1)No
Timsort (Python, Java objects)O(n)O(n log n)O(n log n)O(n)Yes
Introsort (C++ std::sort)O(n log n)O(n log n)O(n log n)O(log n)No
Insertion sortO(n)O(n²)O(n²)O(1)Yes
Selection sortO(n²)O(n²)O(n²)O(1)No
Bubble sort (with early exit)O(n)O(n²)O(n²)O(1)Yes
Shell sortO(n log n)depends on the gapsO(n^(4/3)) with Sedgewick gapsO(1)No
Counting sortO(n + k)O(n + k)O(n + k)O(n + k)Yes
Radix sort (LSD)O(d·(n + b))O(d·(n + b))O(d·(n + b))O(n + b)Yes
Bucket sortO(n + k)O(n + k)O(n²)O(n + k)Yes, with a stable inner sort
Searching and graph algorithms (V vertices, E edges)
AlgorithmTimeSpaceNote
Linear searchO(n)O(1)Any list.
Binary searchO(log n)O(1)Sorted array only.
Breadth-first search (BFS)O(V + E)O(V)Shortest paths in unweighted graphs.
Depth-first search (DFS)O(V + E)O(V)Recursion depth up to V.
Topological sortO(V + E)O(V)Kahn's algorithm or DFS; directed acyclic graphs.
Dijkstra (binary heap)O((V + E) log V)O(V)Non-negative edge weights.
Bellman–FordO(V·E)O(V)Handles negative weights, detects negative cycles.
Floyd–WarshallO(V³)O(V²)All pairs of shortest paths.
Prim (binary heap)O(E log V)O(V)Minimum spanning tree.
KruskalO(E log E)O(V)Minimum spanning tree; sorting the edges dominates.
Matrix multiplication (naive)O(n³)O(n²)n × n matrices.
Generating all subsets / permutationsO(2ⁿ) / O(n!)O(n)Feasible only for small n (about 25 / 11).
How the operation count grows (log base 2)
nO(1)O(log n)O(√n)O(n)O(n log n)O(n²)O(n³)O(2ⁿ)O(n!)
1013.323.161033.221001,0001,0243,628,800
10016.641010066410,0001,000,0001.27 × 10^309.33 × 10^157
1,00019.9731.621,0009,9661,000,0001,000,000,0001.07 × 10^3014.02 × 10^2,567
10,000113.2910010,000132,877100,000,0001,000,000,000,0002.00 × 10^3,0102.85 × 10^35,659
100,000116.61316100,0001,660,96410,000,000,0001.00 × 10^159.99 × 10^30,1022.82 × 10^456,573
1,000,000119.931,0001,000,00019,931,5691,000,000,000,0001.00 × 10^189.90 × 10^301,0298.26 × 10^5,565,708
My tools →
Advertisement

Big O notation describes how the work an algorithm does grows with the size of its input. This cheat sheet collects the time and space complexity of the common data structures (arrays, linked lists, hash tables, balanced trees, heaps, tries), sorting algorithms (with best, average and worst cases and stability) and graph algorithms. A calculator turns a complexity and your input size into an operation count and an estimated run time, which is the quickest way to tell whether an approach will finish in time.

How to use this tool

  1. Enter your input size n.
  2. Pick the complexity of your algorithm.
  3. Adjust the operations per second if you know your platform (about 10⁸ for compiled code).
  4. Read the operation count and estimated time, then compare all complexities at your n in the first table.
  5. Type in the filter box to narrow the reference tables, for example "stable" or "tree".

Formula

operations ≈ f(n) · time ≈ f(n) ÷ operations per second

f(n) is 1, log₂ n, √n, n, n log₂ n, n², n³, 2ⁿ or n!. Counts beyond 10¹⁵ are shown in scientific notation, computed with logarithms (n! with a Kahan-summed log sum, or the log-gamma function above n = 100,000). Real run time also depends on constant factors, memory access patterns and the language, so treat the estimate as an order of magnitude.

Example

Sorting n = 1,000,000 items with an O(n log n) algorithm takes about 1,000,000 × log₂ 1,000,000 ≈ 19.9 million operations — around 0.2 seconds at 10⁸ operations per second. An O(n²) algorithm needs 10¹² operations, about 2.8 hours, which is why quadratic sorts are only used for small inputs.

Frequently asked questions

What is the difference between average and worst case?

The worst case is the maximum work over all inputs of size n; the average case assumes typical or random input. Quicksort averages O(n log n) but can hit O(n²) on adversarial input, which is why libraries use introsort or randomized pivots.

What does amortized O(1) mean?

Most operations are O(1) and an occasional one is expensive, but spread over many operations the cost per operation is constant. Appending to a dynamic array is the classic example: a resize copies everything, but it happens rarely enough that the average stays O(1).

Which base is the logarithm?

In Big O the base does not matter, because logarithms of different bases differ by a constant factor. For the operation counts here, log base 2 is used.

What does stable mean for a sort?

A stable sort keeps equal elements in their original order, which matters when you sort by one key after another.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). Big O Cheat Sheet (with Run-Time Estimator). https://kakao.mobile/tools/big-o-cheat-sheet/

MLA

“Big O Cheat Sheet (with Run-Time Estimator).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/big-o-cheat-sheet/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement