Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solving recurrence T(n) = 2T(n/2) + Θ(1) by substitution

So I am pretty sure it is O(n) (but it might not be?), but how do you solve it with substitution?

If you assume T(n) <= c * n, what is the induction steps?

like image 932
evenodd Avatar asked Sep 15 '14 23:09

evenodd


People also ask

How do you solve a recurrence relation using substitution?

Substitution Method:We make a guess for the solution and then we use mathematical induction to prove the guess is correct or incorrect. We guess the solution as T(n) = O(nLogn). Now we use induction to prove our guess. We need to prove that T(n) <= cnLogn.

What is the solution to the recurrence t'n't n 2 )+ n?

Hence answer is O(N).

What is the complexity of a recurrence relation T n 2t n 1 1?

Time Complexity =O(1).

What will be the time complexity of this relation t/n 2t n 2 n 2?

Hence the complexity of above Algorithm is O(logn).


1 Answers

First of all,I'd like to assume clearly that Θ(1)=k,some constant.

Next,proceeding using substitution method, we get

 T(n)=2T(n/2)+Θ(1)
     =2T(n/2)+k
     =2{2T(n/4)+k)+k
     =4T(n/4)+3k
     =...
     =n.T(1)+(n-1)k
     =n.k+(n-1)k
     =2nk-k
     =O(n).

If you assume it as T(n) <= c * n,you should start with T(1) and assume for T(n) to be correct,and then proceed to show that it is correct for T(n+1) by using the assumption for T(n).

BTW,your assumption was right!

like image 152
Am_I_Helpful Avatar answered Sep 24 '22 19:09

Am_I_Helpful