Big-O Notation · Time Complexity · Space Complexity · Best/Worst/Average Cases
| Big-O | Name | Example | n=10 | n=100 | n=1000 |
|---|---|---|---|---|---|
| O(1) | Constant | Hash table lookup, array access | 1 | 1 | 1 |
| O(log n) | Logarithmic | Binary search, BST search | 3 | 7 | 10 |
| O(n) | Linear | Linear search, traversal | 10 | 100 | 1000 |
| O(n log n) | Linearithmic | Merge sort, quick sort (avg) | 33 | 664 | 10,000 |
| O(n²) | Quadratic | Bubble/insertion sort, nested loops | 100 | 10,000 | 1,000,000 |
| O(2ⁿ) | Exponential | Fibonacci (naive), subset generation | 1,024 | 10³⁰ — impractical | |
| O(n!) | Factorial | Travelling salesman (brute force) | 3,628,800 | Impossible | |