Big-O-Cheat-Sheet
Eine durchsuchbare, druckbare Big-O-Referenz: Zeit- und Speicherkomplexität für Arrays, Hash-Tabellen, Bäume, Heaps, Graphen, Sortieren und Suchen. Kostenlos.
Complexity classes
12O(1): constant
O(log n): logarithmic
O(n): linear
O(n log n): linearithmic
O(n²): quadratic
O(n³): cubic
O(2^n): exponential
O(n!): factorial
n = 10^6: O(n log n) ≈ 2×10^7 ops
n = 10^6: O(n²) = 10^12 ops
Rule: drop constants and lower terms
Amortized O(1)
Arrays & dynamic arrays
11Access by index: O(1)
Search (unsorted): O(n)
Search (sorted): O(log n)
Append (dynamic): O(1) amortized
Insert at front/middle: O(n)
Delete at end: O(1)
Delete at front/middle: O(n)
Resize (grow ×2): O(n)
Slice/copy: O(k)
Space: O(n)
Cache-friendly: contiguous memory
Linked lists
10Access by index: O(n)
Search: O(n)
Insert/delete at head: O(1)
Insert/delete at tail: O(1) with tail ptr
Insert after known node: O(1)
Delete known node (doubly): O(1)
Delete known node (singly): O(n)
Reverse: O(n) time, O(1) space
Detect cycle: O(n), O(1) space
Space: O(n) plus pointer overhead
Stacks & queues
10Stack push/pop/peek: O(1)
Stack search: O(n)
Queue enqueue/dequeue: O(1)
Deque push/pop both ends: O(1)
Queue via 2 stacks: O(1) amortized
Min-stack: O(1) getMin
Monotonic stack: O(n) total
Stack use: DFS, undo, call stack
Queue use: BFS, schedulers, buffers
Space: O(n)
Hash tables
11Insert: O(1) avg, O(n) worst
Lookup: O(1) avg, O(n) worst
Delete: O(1) avg, O(n) worst
Resize/rehash: O(n)
Load factor ~0.7
Chaining
Open addressing
Ordered iteration: not provided
Hash set membership: O(1) avg
Space: O(n)
Pattern: trade O(n) space for O(1) lookups
Binary search trees & balanced trees
12BST search/insert/delete: O(h)
BST average: O(log n)
BST worst: O(n)
AVL all ops: O(log n) guaranteed
Red-black all ops: O(log n)
B-tree all ops: O(log n)
In-order traversal: O(n)
Min/max: O(log n) balanced
Successor/predecessor: O(log n)
Range query: O(log n + k)
Trie lookup: O(L)
Space: O(n)
Heaps
10Peek min/max: O(1)
Insert: O(log n)
Extract min/max: O(log n)
Build heap from array: O(n)
Search arbitrary key: O(n)
Decrease-key: O(log n)
Top-k of n items: O(n log k)
Two heaps: O(log n) per insert
Stored as an array
Space: O(n)
Graphs
12Adjacency list space: O(V + E)
Adjacency matrix space: O(V²)
Edge check: list O(deg), matrix O(1)
Iterate neighbors: list O(deg), matrix O(V)
BFS / DFS: O(V + E)
Topological sort: O(V + E)
Dijkstra: O((V + E) log V)
Bellman-Ford: O(V·E)
Floyd-Warshall: O(V³)
Prim / Kruskal MST: O(E log V)
Union-Find: O(α(n)) ≈ O(1)
A*: O(E) best case
Sorting algorithms
13Bubble sort: O(n²), best O(n)
Insertion sort: O(n²), best O(n)
Selection sort: O(n²) always
Merge sort: O(n log n) always
Quick sort: avg O(n log n), worst O(n²)
Heap sort: O(n log n) always
Tim sort: O(n log n), best O(n)
Counting sort: O(n + k)
Radix sort: O(d·(n + k))
Bucket sort: avg O(n + k), worst O(n²)
Shell sort: ~O(n^1.3)
Comparison-sort lower bound: Ω(n log n)
Stable: merge, insertion, tim, counting
Searching algorithms
11Linear search: O(n)
Binary search: O(log n)
Binary search space: O(1) iterative
Hash lookup: O(1) avg
BST search: O(log n) balanced
Trie prefix search: O(L)
BFS shortest path (unweighted): O(V + E)
lower_bound / bisect: O(log n)
Quickselect (k-th element): avg O(n)
Ternary search: O(log n)
Interpolation search: avg O(log log n)
Common patterns
12Two pointers: O(n)
Sliding window: O(n)
Fast & slow pointers: O(n)
Prefix sums: O(n) build, O(1) query
Binary search on answer: O(n log range)
Monotonic stack: O(n)
Backtracking: O(2^n) or O(n!)
Memoized DP: states × transition cost
Greedy: usually O(n log n)
Divide & conquer: T(n) = 2T(n/2) + O(n)
Bit manipulation: O(1) per op
Meet in the middle: O(2^(n/2))
Space complexity notes
11In-place: O(1) extra space
Recursion costs stack space
DFS space: O(h) / O(V) worst
BFS space: O(w)
Merge sort: O(n) auxiliary
Memoization: O(#states)
DP table row trick: O(n²) → O(n)
Hash-based de-dupe: O(n) space
Tail recursion: O(1) if optimized
Streaming: O(1) or O(k) space
Always state time AND space
Kein Eintrag passt zu „:q“.
Über Big-O-Cheat-Sheet
Dieses Big-O-Cheat-Sheet bringt algorithmische Komplexität auf eine durchsuchbare Seite: die Komplexitätsklassen selbst, dann die Zeit- und Speicherkosten für Arrays und dynamische Arrays, verkettete Listen, Stacks und Queues, Hash-Tabellen, binäre Suchbäume und balancierte Bäume, Heaps, Graphen, Sortieralgorithmen, Suchalgorithmen, gängige Muster sowie Hinweise zur Speicherkomplexität.
Es ist sowohl die Referenz für die Wahl einer Datenstruktur als auch für die Vorbereitung auf Vorstellungsgespräche: der Durchschnitts- und Worst-Case für eine Hash-Tabellen-Suche, warum ein balancierter Baum einen einfachen BST schlägt, welche Sortierungen stabil und welche in-place sind, und was die Two-Pointer-, Sliding-Window- und Memoization-Muster kosten.
Das Sheet ist kostenlos und clientseitig: Filtern Sie Zeilen live mit dem Suchfeld, springen Sie mit dem fixierten Inhaltsverzeichnis zwischen Abschnitten, kopieren Sie jeden Eintrag mit einem Klick und drucken Sie die Seite als Schreibtischreferenz.
So verwenden Sie Big-O-Cheat-Sheet
- Öffnen Sie das Sheet und beginnen Sie mit Komplexitätsklassen, um O(1), O(log n), O(n), O(n log n) und O(n²) zu verankern.
- Suchen Sie nach einer Struktur oder einem Algorithmus wie hash table, quicksort oder BFS, um alle Zeilen live zu filtern.
- Vergleichen Sie die Datenstruktur-Abschnitte, wenn Sie zwischen einer Liste, einer Map und einem Baum wählen.
- Klicken Sie auf einen Eintrag oder sein Kopiersymbol, um ihn in Ihre Zwischenablage zu kopieren.
- Drucken Sie das Sheet für eine Offline-Komplexitätsreferenz.