Major Algorithm Types Cheat Sheet

1. Brute Force

Try all possibilities until you find the answer.

✅ Simple but usually slow (O(2ⁿ), O(n!)).

2. Divide and Conquer

Break problem → solve subproblems → combine results.

🔑 Examples: Merge Sort, Quick Sort, Bina…


This content originally appeared on DEV Community and was authored by davinceleecode

1. Brute Force

  • Try all possibilities until you find the answer.
  • ✅ Simple but usually slow (O(2ⁿ), O(n!)).

2. Divide and Conquer

  • Break problem → solve subproblems → combine results.
  • 🔑 Examples: Merge Sort, Quick Sort, Binary Search.

3. Greedy Algorithms

  • Make the best local choice at each step → hope it leads to global optimum.
  • 🔑 Examples: Dijkstra’s shortest path, Huffman coding.

4. Dynamic Programming (DP)

  • Break problem into overlapping subproblems.
  • Save (memoize) results to avoid recomputation.
  • 🔑 Examples: Fibonacci, Knapsack, Matrix path problems.

5. Backtracking

  • Try a path, if it fails → go back and try another.
  • 🔑 Examples: Sudoku solver, N-Queens, Maze solving.

6. Graph Algorithms

  • Work with nodes/edges (networks, maps, dependencies).
  • 🔑 Examples: BFS, DFS, Dijkstra, Kruskal, Prim.

7. Sorting & Searching

  • Sorting: QuickSort, MergeSort, HeapSort, BubbleSort.
  • Searching: Binary Search, Linear Search.

8. Recursion

  • A function calls itself to solve smaller versions of a problem.
  • Often combined with DP, divide & conquer, backtracking.

9. Mathematical / Number Theory

  • 🔑 Examples: GCD (Euclidean), Prime tests, Modular arithmetic.

10. String Algorithms

  • Work on text patterns and substrings.
  • 🔑 Examples: KMP, Rabin-Karp, Trie-based search.

TL;DR

  • Optimization → Greedy or DP.
  • Paths/Networks → Graph.
  • Exploring possibilities → Backtracking.
  • Ordering/Searching data → Sorting/Searching.
  • Formula-style tricks → Math/Number theory.

If you found this helpful, consider supporting my work at ☕ Buy Me a Coffee.


This content originally appeared on DEV Community and was authored by davinceleecode


Print Share Comment Cite Upload Translate Updates
APA

davinceleecode | Sciencx (2025-08-22T07:19:00+00:00) Major Algorithm Types Cheat Sheet. Retrieved from https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/

MLA
" » Major Algorithm Types Cheat Sheet." davinceleecode | Sciencx - Friday August 22, 2025, https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/
HARVARD
davinceleecode | Sciencx Friday August 22, 2025 » Major Algorithm Types Cheat Sheet., viewed ,<https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/>
VANCOUVER
davinceleecode | Sciencx - » Major Algorithm Types Cheat Sheet. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/
CHICAGO
" » Major Algorithm Types Cheat Sheet." davinceleecode | Sciencx - Accessed . https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/
IEEE
" » Major Algorithm Types Cheat Sheet." davinceleecode | Sciencx [Online]. Available: https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/. [Accessed: ]
rf:citation
» Major Algorithm Types Cheat Sheet | davinceleecode | Sciencx | https://www.scien.cx/2025/08/22/major-algorithm-types-cheat-sheet/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.