On this page
  1. Complexity & Big-O Notation
  2. Contents
  3. Common Growth Classes
  4. Amortized Complexity & Cache Reality

Complexity & Big-O Notation

Prev: algorithms_and_dsa | Up: algorithms_and_dsa | Next: Linear & Hashed Structures
Rel: Pointers & CPU Cache Locality
Ref: Wikipedia — Big O Notation
Tags: #public #prog #programming #algorithms #big-o


Contents


Common Growth Classes

Big-O describes how runtime or memory scales as input size $n \to \infty$ (dropping constant factors and lower-order terms):

Complexity Name Typical Example
$O(1)$ Constant Array index lookup, hash table lookup (avg)
$O(\log n)$ Logarithmic Binary search, balanced BST / B-Tree lookup
$O(n)$ Linear Single pass over an array or list
$O(n \log n)$ Linearithmic Merge sort, Timsort, heapsort
$O(n^2)$ Quadratic Nested loops comparing all pairs
$O(2^n)$ Exponential Unmemoized recursive subsets / naive Fibonacci

Amortized Complexity & Cache Reality

Linked from

Related notes