<aside>
ℹ️ Sources :
</aside>
Algorithms can be classified into a few general types. These include:
- Divide and Conquer Algorithms: These algorithms work by repeatedly breaking down a problem into one or more sub-problems of the same or related type, until these become simple enough to be solved directly. Examples include quicksort, mergesort, and binary search.
- Dynamic Programming Algorithms: These algorithms solve a complex problem by breaking it down into simpler sub-problems in a recursive manner. However, unlike divide and conquer algorithms, these sub-problems are not solved independently. Rather, results of sub-problems are used to solve the next sub-problem in a way that avoids solving the same problem multiple times. Examples include the Knapsack problem and the Longest Common Subsequence problem.
- Greedy Algorithms: These algorithms make locally optimal choices at each step in the hope that these choices will lead to a globally optimal solution. Examples include Kruskal's algorithm and Dijkstra's algorithm.
- Brute Force Algorithms: These algorithms try all possibilities until a satisfactory solution is found. Such algorithms are generally simple to implement, but they are not efficient in the long run. Examples include linear search and the traveling salesman problem via brute-force search.
- Randomized Algorithms: These algorithms use a random number at least once during the computation to make decisions. Examples include Randomized QuickSort and Monte Carlo algorithm.