- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Advanced master theorem for divide and conquer recurrences
45 Lectures 4.5 hours
66 Lectures 5.5 hours
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>bk, then T(n) = ∅ (nlogba)
- If a = bk, then
- If p> -1, then T(n) = ∅(nlogba logp+1n)
- If p = -1, then T(n) = ∅(nlogba loglogn)
- If p < -1, then T(n) = ∅(nlogba)
- If a<bk , then
- If p> = 0, then T(n)= ∅(nklogpn)
- If p< 0, then T(n) = ∅(nk)
Using the advanced master algorithm, we will calculate the complexity of some algorithms −
Binary search − t(n) = θ(logn)
Merge sort − T(n) = θ(nlogn)
- 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
- C++ Program to Search Sorted Sequence Using Divide and Conquer with the Aid of Fibonacci Numbers
- 4 computer skills to master for online education
- Top 10 websites for Advanced level Java developers
- C++ Program for Zeckendorf's Theorem?
- Signals and Systems – Parseval’s Theorem for Laplace Transform
- Bayes Theorem for Conditional Probability in C/C++
- Basic Slicing and Advanced Indexing in NumPy Python
- Explain AllowEmptyString() and AllowEmptyCollection() in PowerShell Advanced Function.
- Advanced Mobile Phone System