5.7.25

Algorithm paradigms

Algorithm Paradigms

1. Divide and Conquer

  • Break down a problem into smaller sub-problems
  • Solve each sub-problem recursively
  • Combine the solutions to the sub-problems to solve the original problem
  • Examples: Merge Sort, Quick Sort, Binary Search

2. Dynamic Programming

  • Break down a problem into smaller sub-problems
  • Solve each sub-problem only once and store the solution
  • Use the stored solutions to solve larger problems
  • Examples: Fibonacci Series, Longest Common Subsequence, Shortest Path Problems

3. Greedy Algorithm

  • Make the locally optimal choice at each step
  • Hope that the local choices will lead to a global optimum solution
  • Examples: Huffman Coding, Activity Selection Problem, Fractional Knapsack Problem

4. Backtracking

  • Explore all possible solutions by recursively adding choices
  • Backtrack when a dead end is reached
  • Examples: N-Queens Problem, Sudoku, Maze Solving

5. Brute Force

  • Try all possible solutions
  • Check each solution to see if it satisfies the problem constraints
  • Examples: Finding the maximum or minimum value in an array, Checking if a string is a palindrome

6. Recursive Algorithm

  • Solve a problem by breaking it down into smaller instances of the same problem
  • Use recursive function calls to solve the problem
  • Examples: Factorial, Fibonacci Series, Tree Traversal

No comments:

Post a Comment

Difference between File and Folder

10 Differences Between Files and Folders Definition: File: A collection of data or information stored on a computer. ...