Site icon i2tutorials

DAA- Divide and Conquer 

Divide and Conquer 

 

What is Divide and Conquer?

In the divide and conquer approach, firstly a problem is divided into smaller problems, then these smaller problems are solved independently, and then finally the solutions of these smaller problems are combined or merged in order to get a solution for the large or the main problem. 

 

The divide and Conquer algorithm can be divided into the following three steps.

 

Divide: Divide the original problem into a set of smaller problems or subproblems.

Conquer: Solve every subproblem individually and repeat it i.e., recursively.

Combine: Here, we put together or merge the solutions of the subproblems in order to get the solution for the whole problem.

 

Examples of the Divide and Conquer approach:

  1. Maximum and Minimum Problem
  2. Binary Search
  3. Sorting (merge sort, quick sort)
  4. Tower of Hanoi.

 

Fundamentals of the Divide and Conquer Strategy:

There are two fundamentals of the Divide and Conquer Strategy. Let us a look at them.

  1. Relational Formula
  2. Stopping Condition

 

  1. Relational Formula: Relational formula is something that we generate from the given technique. Once the formula is generated, we apply the Divide and Conquer Strategy, i.e., we break the problem recursively and solve the subproblems that are broken.
  2. Stopping Condition: Whenever we break the problem using the Divide and Conquer approach, we must have an idea of how much time we require in order to apply the strategy of Divide and Conquer. So, wherever the condition to stop our recursion of Divide and Conquer occurs, that condition is called a Stopping Condition.

 

Advantages of Divide and Conquer

 

Disadvantages of Divide and Conquer

 

Applications of Divide and Conquer:

Binary Search 

The binary search algorithm is a searching algorithm which is also known as the half-interval search or logarithmic search algorithm.

 

QuickSort

It is the most efficient sorting algorithm, it is also called the partition-exchange sort.

 

MergeSort

Merge sort is another sorting algorithm. This algorithm divides the array into two halves, then recursively sorts them, and finally merges the two sorted halves.

 

Strassen’s Matrix Multiplication

It is an algorithm for the multiplication of matrices. It is named after Volker Strassen. It has proven to be much faster than the traditional algorithm while working with large matrices.

 

Closest Pair of Points

This algorithm of the closest pair of points emphasizes finding out the closest pair of points in a metric space where we are given n points, such that the distance between the points is minimal.

 

Cooley-Tukey Fast Fourier Transform (FFT) algorithm: The Cooley-Tukey Fast Fourier Transform algorithm is named after J. W. Cooley and John Turkey. It follows the approach of Divide and Conquer and has a complexity of O(nlogn).

 

Karatsuba algorithm for fast multiplication: It is one of the fastest multiplication algorithms of the traditional time which is invented by Anatoly Karatsuba in the late 1960 and got published in 1962. It multiplies two n-digit numbers in such a way that it reduces it to at most single-digit.

 

Algorithm for Divide and Conquer Strategy:

DAC(x, i, j)
{
    if(small(x, i, j))
         return(Solution(x, i, j))
    else 
         k = divide(x, i, j)                    // f1(n)
         p = DAC(x, i, mid)                 // T(n/2)
         q = DAC(x, mid+1, j)             // T(n/2)
         r = combine(p, q)                  // f2(n)
   return(r)
}

 

The recurrence relation for the Divide and Conquer strategy is given as :

    T(n) = O(1) if n is small
           f1(n) + 2T(n/2) + f2(n)

This is all about the divide and conquer strategy. Take a look over the next articles to know in brief about all the applications of the Divide and Conquer strategy.

 

Exit mobile version