Big O Complexity Cheat Sheet
The Big O Complexity Cheatsheet helps you understand and compare algorithm performance using common time and space complexity classes. Use the chart to identify how algorithms scale as input size increases.
Look up an algorithm's complexity
Time and space complexity
| Algorithm | Best | Average | Worst | Space |
|---|
What Is a Big O Complexity Cheatsheet?
A Big O Complexity Cheatsheet is a quick reference guide that summarizes algorithm efficiency, including constant, logarithmic, linear, quadratic, and exponential complexity. It helps programmers analyze code performance and choose efficient algorithms.
How to Use the Big O Complexity Cheatsheet
Identify the operation: Determine which part of the algorithm you want to analyze.
Check input size: Use n to represent the number of input elements.
Estimate complexity: Identify how the number of operations grows with input size.
Compare algorithms: Use the chart to evaluate time and space efficiency.
Consider practical performance: Remember that Big O describes growth rate, not exact execution time.
Big O Complexity Examples
O(1) — Constant: Accessing an array element by index.
O(log n) — Logarithmic: Searching a sorted array using binary search.
O(n) — Linear: Traversing every element in an array.
O(n log n) — Linearithmic: Sorting elements using merge sort.
O(n²) — Quadratic: Comparing every pair of elements using nested loops.
O(2ⁿ) — Exponential: Generating all subsets of a set.
O(n!) — Factorial: Generating all permutations of a collection.