Reference Resources
Data Structure Operation Complexity Cheat Sheet
| Data Structure | insert | Delete | Find | Iteration |
|---|---|---|---|---|
| arrays | O(n) middle / O(1) end | O(n) middle / O(1) end | O(1) index / O(n) value | O(n) |
| Singly linked list | O(1) head / O(n) tail | O(1) head / O(n) specified | O(n) | O(n) |
| Doubly linked list | O(1) (known position) | O(1) (known position) | O(n) | O(n) |
| Stack | O(1) | O(1) | — | — |
| Queue | O(1) | O(1) | — | — |
| Priority Queue (Heap) | O(log n) | O(log n) | — | — |
| Binary Tree (BST) | O(log n)~O(n) | O(log n)~O(n) | O(log n)~O(n) | O(n) |
| Hash table | O(1) average | O(1) average | O(1) average | — |
| Heap | O(log n) | O(log n) | O(1) heap top | — |
| Graph | O(1) adjacency list | O(E) | O(V+E) DFS/BFS | O(V+E) |
Sorting Algorithm Cheat Sheet
| Algorithm | Average Complexity | Worst-case Complexity | Space | Stable | One-line Summary |
|---|---|---|---|---|---|
| Bubble | O(n²) | O(n²) | O(1) | Is | Simple but slow, good for teaching |
| Choice | O(n²) | O(n²) | O(1) | No | Fewest number of swaps |
| insert | O(n²) | O(n²) | O(1) | Is | Optimal for small scale or nearly sorted data |
| Quick | O(n log n) | O(n²) | O(log n) | No | General first choice, with an elegant partitioning idea |
| Merge | O(n log n) | O(n log n) | O(n) | Is | Stable performance but needs extra space |
| Heap Sort | O(n log n) | O(n log n) | O(1) | No | In-place sorting, optimal space |
| Shell | O(n^1.3) | O(n²) | O(1) | No | An improved version of insertion sort |
Big O Complexity Ranking
| Complexity | n=10 | n=1000 | n=1000000 | Evaluation |
|---|---|---|---|---|
| O(1) | 1 | 1 | 1 | Optimal |
| O(log n) | ~3 | ~10 | ~20 | Excellent |
| O(n) | 10 | 1000 | 1000000 | Acceptable |
| O(n log n) | ~30 | ~10000 | ~20000000 | Fair |
| O(n²) | 100 | 1000000 | 10¹² | Beware |
| O(2ⁿ) | 1024 | Astronomical | Impossible | Unusable |
Recommended Learning Resources
| Type | Name | Description |
|---|---|---|
| Classic Textbooks | "Data Structures (C Language Edition)" by Yan Weimin | The standard textbook in Chinese universities, with a complete system |
| Classic Textbooks | "Introduction to Algorithms" (CLRS) | An authoritative reference in the field of algorithms, deep and systematic |
| Online Practice | LeetCode (leetcode.com) | A huge number of algorithm problems, the top choice for interview prep |
| Online Practice | Nowcoder (nowcoder.com) | A domestic interview practice platform, suitable for campus recruitment preparation |
| Visualization Tools | Visualgo (visualgo.net) | Algorithm visualization, helping understand the execution process |
| Online Compiler | Compiler Explorer (godbolt.org) | View the assembly generated from C code compilation to understand the low level |