The sequence of steps we need to take to solve a particular problem is known as an algorithm. There are so many algorithms in computer science that fall under the categories of different types of algorithms. So, if you want to learn more about the types of algorithms in computer science, this article is for you. In this article, I will introduce you to the types of algorithms that you need to know.

## Types of Algorithms

We perform so many activities in our daily life by following a sequence of steps. This sequence of steps is nothing but an algorithm. Learning algorithms helps you solve real-world problems with your coding skills and also helps you in performing well in the coding interviews. Below are all the types of algorithms you need to know:

**Recursive****Graph****Dynamic Programming****Backtracking****Divide and Conquer****Greedy**

So these are the types of algorithms that you need to know. Now let’s go through all the types of algorithms one by one.

#### Recursive Algorithms:

Recursive algorithms are based on the concepts of reductions, which means reducing one problem A to another problem B. In simple terms, it means writing an algorithm for A that uses an algorithm for B as a subroutine. Thus, recursive algorithms can be described as if the given instance of a problem can be solved directly, then solve it directly or reduce it to one or simpler instances of the same problem. Here are some examples of using recursive algorithms:

**Calculating the sum of an array of numbers****Fibonacci Series****Calculating Factorials****Sorting a list or an array of numbers**

#### Graph Algorithms:

Graph algorithms are used to analyze the connected data. The mathematical calculations of graph algorithms are based on understanding the relationships between data. These algorithms use the relationships between nodes to infer the organization and dynamics of complex systems. In the real world, **Network Scientists** use these algorithms to uncover hidden information and make predictions about behaviour. Some of the popular graph algorithms are:

**Bellman-Ford algorithm****Dijkstraâ€™s algorithm****Ford-Fulkerson algorithm****Kruskalâ€™s algorithm****Nearest Neighbor algorithm****Primâ€™s algorithm****Depth-first search****Breadth-first search**

#### Dynamic Programming Algorithms:

Dynamic programming is a concept widely used for optimization. This is to simplify a complicated problem by breaking it down into simple subproblems recursively. To solve a problem using dynamic programming, the problem must have two key attributes:

**Optimal substructure****Overlapping subproblems**

The idea behind solving a problem using dynamic programming is to break a complex problem down into several small, simple problems.

#### Backtracking Algorithms:

Backtracking algorithms are used to define a solution to a computational problem incrementally by solving a small part of the problem at a time. Each time the algorithm has to decide between several alternatives for the next part of the problem, it recursively evaluates each alternative to choose the best solution for the problem. These algorithms are commonly used to make a sequence of decisions to build a recursively defined structure satisfying certain constraints. Some of the popular examples where backtracking algorithms can be used in coding interviews are:

**N Queens problem****Game trees****Subset Sum****Text Segmentation****Binary Search Trees**

#### Divide and Conquer Algorithms:

The divide and conquer algorithms solve a problem by:

- dividing the problem into subproblems which are themselves smaller instances of the same problem
- solving the problem recursively
- and then combining the solutions of all the subproblems to frame a final solution.

Some of the popular algorithms based on the divide and conquer strategy are:

#### Greedy Algorithms:

When solving a problem, greedy algorithms choose between all possible solutions that can provide the best solution depending on the problem. It builds an object to take one step at a time to choose the best option at each step. This is why the name of this technique is greedy because it frames a solution by choosing the best possible solution for the problem. Here are some examples of Greedy algorithms:

**Primâ€™s Minimal Spanning Tree****Travelling Salesman problem****Kruskalâ€™s Minimal Spanning Tree****Dijkstraâ€™s Minimal Spanning Tree**

### Summary

So these were the algorithms that you should know while solving the problems based on data structures and algorithms. Learning algorithms helps you solve real-world problems with your coding skills and also helps you in performing well in the coding interviews. Below are the types of algorithms that you should know:

**Recursive****Graph****Dynamic Programming****Backtracking****Divide and Conquer****Greedy**

I hope you liked this article on the types of algorithms you should know. Feel free to ask your valuable questions in the comments section below.