- Related Questions & Answers
- Introduction to Divide & Conquer Algorithms
- Maximum Sum SubArray using Divide and Conquer in C++
- Convex Hull using Divide and Conquer Algorithm in C++
- Maximum Subarray Sum using Divide and Conquer algorithm in C++
- Python Program to solve Maximum Subarray Problem using Divide and Conquer
- Implement divide & conquer logic in JavaScript to implement QuickSort
- C++ Program to Search Sorted Sequence Using Divide and Conquer with the Aid of Fibonacci Numbers
- C++ Program for Zeckendorf's Theorem?
- 4 computer skills to master for online education
- Bayes Theorem for Conditional Probability in C/C++
- Top 10 websites for Advanced level Java developers
- Basic Slicing and Advanced Indexing in NumPy Python
- Explain AllowEmptyString() and AllowEmptyCollection() in PowerShell Advanced Function.
- Kirchoff's Theorem
- Advanced Mobile Phone System

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

**Divide and conquer** is an algorithm that works on the paradigm based on recursively branching problem into multiple sub-problems of similar type that can be solved easily.

Let’s take an example to learn more about the divide and conquer technique −

function recursive(input x size n) if(n < k) Divide the input into m subproblems of size n/p. and call f recursively of each sub problem else Solve x and return

Combine the results of all subproblems and return the solution to the original problem.

**Explanation** − In the above problem, the problem set is to be subdivided into smaller subproblems that can be solved easily.

**Masters Theorem for divide and conquer** is an analysis theorem that can be used to determine a big-0 value for recursive relation algorithms. It is used to find the time required by the algorithm and represent it in asymptotic notation form.

Example of runtime value of the problem in the above example −

T(n) = f(n) + m.T(n/p)

For most of the recursive algorithm, you will be able to find the Time complexity For the algorithm using the master's theorem, but there are some cases master's theorem may not be applicable. These are the cases in which the master's theorem is not applicable. When the problem T(n) is not monotone, for example, T(n) = sin n. Problem function f(n) is not a polynomial.

As the master theorem to find time complexity is not hot efficient in these cases, and advanced master theorem for recursive recurrence was designed. It is design to handle recurrence problem of the form −

T(n) = aT(n/b) + ø((n^k)logpn)

Where n is the size of the problem.

a = number of subproblems in recursion, a > 0

n/b = size of each subproblem b > 1, k >= 0 and p is a real number.

For solving this type of problem, we will use the following solutions,

- If a>b
_{k}, then T(n) = ∅ (nlogba) - If a = b
_{k}, then- If p> -1, then T(n) = ∅(nlogba log
^{p+1}n) - If p = -1, then T(n) = ∅(nlog
_{ba}loglogn) - If p < -1, then T(n) = ∅(nlog
_{ba})

- If p> -1, then T(n) = ∅(nlogba log
- If a<b
_{k}, then- If p> = 0, then T(n)= ∅(n
_{k}log_{p}n) - If p< 0, then T(n) = ∅(nk)

- If p> = 0, then T(n)= ∅(n

Using the advanced master algorithm, we will calculate the complexity of some algorithms −

**Binary search** − t(n) = θ(logn)

**Merge sort** − T(n) = θ(nlogn)

Advertisements