Questions tagged [master-theorem]

In the analysis of algorithms, the Master theorem provides a cookbook solution in asymptotic terms (using Big O notation) for recurrence relations of types that occur in the analysis of many divide and conquer algorithms.

In the analysis of algorithms, the Master theorem provides a cookbook solution in asymptotic terms (using Big O notation) for recurrence relations of types that occur in the analysis of many divide and conquer algorithms. It was popularized by the canonical algorithms textbook Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein, in which it is both introduced and proved. Nevertheless, not all recurrence relations can be solved with the use of the master theorem; its generalizations include the Akra–Bazzi method.

182 questions
9
votes
1 answer

Solving recurrence equation without the Master's Theorem

So, on a previous exam, I was asked to solve the following recurrence equation without using the Master Theorem: T(n)= 9T(n/3) + n^2 Unfortunately, I couldn't figure it out on the exam, so I used solved it using the Master's Theorem just so I could…
busebd12
  • 997
  • 2
  • 12
  • 24
8
votes
2 answers

Understanding Master Theorem

Generic form: T(n) = aT(n/b) + f(n) So i must compare n^logb(a) with f(n) if n^logba > f(n) is case 1 and T(n)=Θ(n^logb(a)) if n^logba < f(n) is case 2 and T(n)=Θ((n^logb(a))(logb(a))) Is that correct? Or I misunderstood something? And what about…
a1204773
  • 6,923
  • 20
  • 64
  • 94
7
votes
2 answers

Master theorem: issue when f(n) contains negative power of log

So I was calculating average case complexity of the following function using Master's theorem: T(n) = 2T (n/2)+ n/ log n According to http://people.csail.mit.edu/thies/6.046-web/master.pdf Question 7, It says Does not apply (non-polynomial…
Varun Garg
  • 2,464
  • 23
  • 37
7
votes
2 answers

time complexity of relation T(n) = T(n-1) + T(n/2) + n

for the relation T(n) = T(n-1) + T(n/2) + n can I first solve the term (T(n-1) + n) which gives O(n^2), then solve the term T(n/2) + O(n^2) ? according to the master theorem which also gives O(n ^ 2) or it is wrong?
6
votes
1 answer

Master Theorem: Why is T(n)=16T(n/4)+n! considered Θ(n!)

I am having some problem trying to understand why T(n)=16T(n/4)+n! is considered Θ(n!) I am using the following master theorem below from here: https://www.geeksforgeeks.org/advanced-master-theorem-for-divide-and-conquer-recurrences/ The…
Belphegor
  • 1,683
  • 4
  • 23
  • 44
6
votes
1 answer

When can the Master Theorem actually be applied?

I am quite frustrated over this. In CLRS 3rd edition, page 95 (chapter 4.5), it mentions that recurrences like T(n) = 2T(n/2) + n lg n cannot be solved with the Master Theorem because the difference f(n)/n^(log_b(a)) = (n lg n)/n^1 = lg n is not…
AJJ
  • 2,004
  • 4
  • 28
  • 42
6
votes
5 answers

How do I use Master theorem to describe recursion?

Recently I have been studying recursion; how to write it, analyze it, etc. I have thought for a while that recurrence and recursion were the same thing, but some problems on recent homework assignments and quizzes have me thinking there are slight…
Zachary Wright
  • 23,480
  • 10
  • 42
  • 56
6
votes
3 answers

Master's theorem with f(n)=log n

For master's theorem T(n) = a*T(n/b) + f(n) I am using 3 cases: If a*f(n/b) = c*f(n) for some constant c > 1 then T(n) = (n^log(b) a) If a*f(n/b) = f(n) then T(n) = (f(n) log(b) n) If a*f(n/b) = c*f(n) for some constant c < 1 then T(n) =…
amir shadaab
  • 469
  • 3
  • 9
  • 23
5
votes
1 answer

What are the asymptotic upper and lower bounds for T(n) = 2T(n/2) + n lg lg n?

The recurrence relation T(n) = 2T(n/2) + n lg lg n (where lg is logarithm to base 2) can be solved using the master theorem but I am not very sure about the answer. I have found my answer but am not mentioning it here in order to prevent…
Programmer
  • 6,565
  • 25
  • 78
  • 125
5
votes
2 answers

Algorithm complexity, solving recursive equation

I'm taking Data Structures and Algorithm course and I'm stuck at this recursive equation: T(n) = logn*T(logn) + n obviously this can't be handled with the use of the Master Theorem, so I was wondering if anybody has any ideas for solving this…
4
votes
4 answers

Can not figure out complexity of this recurrence

I am refreshing on Master Theorem a bit and I am trying to figure out the running time of an algorithm that solves a problem of size n by recursively solving 2 subproblems of size n-1 and combine solutions in constant time. So the formula is: T(N) =…
3
votes
1 answer

Understanding the lambda as it applies to the Master Theorem

Suppose i have a case like T(n)=2T(n/4)+1. f(n)=1 a=2 and b=4. Thus n^(1/2)>1. That should be case 1. However there is also a lambda in case 1, so that f(n)=O(n^((1/2)-lambda)) for some lambda >0. In this case lambda would be 1/2?
Jake
  • 2,877
  • 8
  • 43
  • 62
3
votes
1 answer

Divide and Conquer to solve the power of a number, runtime analysis with master theorem

I implemented a divide and conquer algorithm to calculate the power of a number: public static void main(String[] args) { System.out.println("Result: " + pow(2, 1)); System.out.println("Result: " + pow(2, 9)); System.out.println("Result:…
Moritz Schmidt
  • 2,635
  • 3
  • 27
  • 51
3
votes
1 answer

What will be the time complexity of following recursive algorithm?

What will be the complexity of following recursive algorithm? void rec(n){ if(n<=0) return; else rec(n/3)+rec(n/2); }
Avenash
  • 85
  • 1
  • 4
3
votes
1 answer

Master theorem with f(n)=n!?

How do I solve the following as f(n)=n! does not as to my knowledge apply to any of the cases of master theorem. T (n) = 16T (n/4) + n!
Harshitha G
  • 39
  • 1
  • 2
1
2 3
12 13