Divide and Conquer
Divide and Conquer
Methodology
Concept:
• Divide and Conquer is an algorithmic
paradigm that solves a problem by breaking it
down into smaller subproblems. Each
subproblem is solved independently, and
then the solutions to the subproblems are
combined to form the solution to the original
problem.
Methodology:
1. Divide: Split the problem into smaller, more
manageable subproblems.
2. Conquer: Solve each subproblem
independently. If a subproblem is still too
large, apply the divide and conquer approach
recursively.
3. Combine: Merge the solutions of the
subproblems to obtain the solution to the
original problem.
Examples:
1. Binary Search:
o Divide: The array is divided into two
halves.
o Conquer: Determine which half contains
the target element.
o Combine: The solution is directly found
by narrowing down the search to one
half.
2. Merge Sort:
o Divide: The array is divided into two
halves.
o Conquer: Each half is sorted recursively
using merge sort.
o Combine: The two sorted halves are
merged to produce a single sorted array.
3. Quick Sort:
o Divide: Choose a pivot element and
partition the array such that elements
less than the pivot are on one side, and
elements greater than the pivot are on
the other.
o Conquer: Recursively apply quick sort to
the partitions.
o Combine: Since quick sort sorts in place,
no additional combination step is
necessary.
4. Strassen’s Matrix Multiplication:
o Divide: The matrices are divided into
smaller submatrices.
o Conquer: Apply Strassen’s algorithm to
multiply the submatrices.
o Combine: The submatrices are combined
to form the final product matrix.