Last Updated: November 21, 2025
Algorithms
Common algorithms and techniques
Sorting Algorithms
| Algorithm | Time Complexity | Space |
|---|---|---|
Bubble Sort
|
O(n²) | O(1) |
Selection Sort
|
O(n²) | O(1) |
Insertion Sort
|
O(n²) | O(1) |
Merge Sort
|
O(n log n) | O(n) |
Quick Sort
|
O(n log n) avg | O(log n) |
Heap Sort
|
O(n log n) | O(1) |
Radix Sort
|
O(nk) | O(n+k) |
Searching Algorithms
| Item | Description |
|---|---|
Linear Search
|
O(n) - Check each element |
Binary Search
|
O(log n) - Sorted array only |
DFS
|
Depth-first search in graphs |
BFS
|
Breadth-first search in graphs |
Dijkstra
|
Shortest path (weighted) |
A*
|
Heuristic pathfinding |
Algorithm Techniques
- Divide and Conquer: Break into subproblems
- Dynamic Programming: Store subproblem solutions
- Greedy: Make locally optimal choices
- Backtracking: Try all possibilities with pruning
- Two Pointers: Efficient array traversal
- Sliding Window: Fixed-size range processing
Graph Algorithms
| Item | Description |
|---|---|
DFS
|
Explore depth-first |
BFS
|
Explore level by level |
Dijkstra
|
Shortest path |
Bellman-Ford
|
Shortest path (negative weights) |
Floyd-Warshall
|
All pairs shortest path |
Kruskal/Prim
|
Minimum spanning tree |
Topological Sort
|
DAG ordering |
š” Pro Tips
Quick Reference
Master problem-solving techniques