BCA / B.Tech 11 min read

What is an Algorithm?

What is an Algorithm in Data Structures:


An algorithm is a definite and ordered process designed to solve a problem or execute a task. It is a sequence of steps that are followed to find a solution to a problem. In simple terms, it can be called a "step-by-step process" whose purpose is to achieve a specific goal or result.

Characteristics of an Algorithm:

  • Input: An algorithm must have at least one input.
  • Output: The result or output of the algorithm must be clear and well-defined.
  • Definiteness: Each step of the algorithm must be described clearly and precisely.
  • Finiteness: The algorithm must end after a finite amount of time.
  • Effectiveness: Each step of the algorithm must be simple and effectively implementable.

Types of Algorithms:

1. Brute Force Algorithm: A simple algorithm that checks all possible solutions to find the correct one. Examples: Linear Search, Bubble Sort.
2. Divide and Conquer Algorithm: The problem is divided into smaller parts, each part is solved, and then they are combined. Examples: Merge Sort, Quick Sort.
3. Greedy Algorithm: At each step, it chooses the option that seems best at the moment, i.e., it selects a "local optimal solution." Examples: Kruskal's Algorithm, Prim's Algorithm.
4. Backtracking Algorithm: A recursive algorithm that checks all possible solutions and backtracks if a choice turns out to be wrong. Examples: N-Queens problem, Sudoku solver.
5. Dynamic Programming Algorithm: Used when a problem can be divided into smaller subproblems, and the solutions to these subproblems can be reused in later steps. Examples: Fibonacci Series, Longest Common Subsequence.
6. Recursive Algorithm: A function calls itself repeatedly until the problem is solved. Examples: Factorial calculation, Fibonacci Series.
7. Graph Algorithm: Used to process graph structures. Examples: Depth First Search (DFS), Breadth First Search (BFS).