Definition of an Algorithm According to Wikipedia: In mathematics and computer science, an algorithm is a finite sequence of well-defined, computer-implementable instructions, typically to solve a class of problems or to perform a computation. Algorithms are always unambiguous and are used as specifications for performing calculations, data processing, automated reasoning, and other tasks. Types of Algorithms Tens of types of algorithms can be found in the literature. The six most recognized1 ones are: 1. Recursive Algorithm This is one of the most interesting Algorithms as it calls itself with a smaller value as inputs which it gets after solving for the current inputs. In more simpler words, It’s an Algorithm that calls itself repeatedly until the problem is solved. https://www.freecodecamp.org/news/how-recursion-works-explained-with-flowcharts-and-a-video-de61f40cb7f9/ 2. Divide and Conquer Algorithm This is another effective way of solving many problems. In Divide and Conquer algorithms, divide the algorithm into two parts, the first parts divides the problem on hand into smaller subproblems of the same type. Then on the second part, these smaller problems are solved and then added together (combined) to produce the final solution of the problem. https://www.khanacademy.org/computing/computer-science/algorithms/merge-sort/a/divide-and-conquer-algorithms 3. Dynamic Programming Algorithm These algorithms work by remembering the results of the past run and using them to find new results. In other words, dynamic programming algorithm solves complex problems by breaking it into multiple simple subproblems and then it solves each of them once and then stores them for future use. Fibonacci sequence is a good example for Dynamic Programming algorithms: https://dzone.com/articles/memoization-make-recursive-algorithms-efficient 4. Greedy Algorithm These algorithms are used for solving optimization problems. In this algorithm, we find a locally optimum solution (without any regard for any consequence in future) and hope to find the optimal solution at the global level. The method does not guarantee that we will be able to find an optimal solution. The algorithm has 5 components:
- The first one is a candidate set from which we try to find a solution.
- A selection function which helps choose the best possible candidate.
- A feasibility function which helps in deciding if the candidate can be used to find a solution.
- An objective function which assigns value to a possible solution or to a partial solution
- Solution function that tells when we have found a solution to the problem