• Divide and Conquer is a problem-solving strategy used in algorithms
where a problem is broken down into smaller subproblems, solved
recursively, and then combined to get the final solution.
• Steps of Divide and Conquer:
• Divide:
• Split the problem into smaller subproblems of the same type.
• Conquer:
• Solve the subproblems recursively. If they are small enough, solve them
directly.
• Combine:
• Merge the solutions of the subproblems to form the final solution.
• Examples of Divide and Conquer Algorithms:
• Merge Sort:
• Divides the array into halves, sorts each half, and then merges them.
• Quick Sort:
• Picks a pivot, partitions the array around the pivot, and sorts recursively.
• Binary Search:
• Divides the sorted array into two halves and searches in the relevant half.
• Strassen’s Matrix Multiplication:
• Breaks a matrix multiplication problem into smaller matrix operations.
where f(n) is a function that accounts for the time spent on dividing an instance of size
n into instances of size n/b and combining their solutions. (For the sum example
above, a =b =2 and f(n)=1.) Recurrence (5.1) is called the general divide-and-
conquerrecurrence.Obviously,theorderofgrowthofitssolutionT(n) depends on the
values of the constants a and b and the order of growth of the function f(n).