edited by
1,436 views
1 votes
1 votes

What is the worst case time complexity of the following recurrence relation?
T(n)=T(n/2)+T(n/4)+T(n/8)+n

  1.   Θ(nlogn)
  2.   Θ(n2)
  3.   Θ(n)

-----------------------------------------------------------------------------------------------------------------------------------------------

i am solving like this

T(n) <  3*T(n/2) + n (because n/2 is largest of n/4 and n/8)

from masters'theorem,its T(n) will be theta(n^3 base 2) but that is equal to n^1.58 =O(n^1.58)

so,this is not giving O(n) which is the answer..what is wrong in this approach..??by tree method,i will get O(n).but whats wrong with this?

please clear ths.

edited by

1 Answer

0 votes
0 votes
The no. of elements compared at each level are getting reduced in worst case as well which drives the complexity towards O(n) therefore the time complexity may not be computed by 3*T(n/2)+n because in this at each level the no. of elements get compared increases

Related questions

2 votes
2 votes
2 answers
1
Amar Vashishth asked Aug 2, 2015
2,422 views
int fun(int n) { int count=0; for (int i= n; i 0; i/=2) for(int j=0; j< i; j++) count+= 1; return count; }
2 votes
2 votes
1 answer
2
Ashwani Kumar 2 asked Sep 8, 2016
3,451 views
1. T(n) = T(n-a) + T(a) + cn2. T(n) = T(αn) + T( (1-α)n ) + cnwhere α, a and c are constant.
1 votes
1 votes
3 answers
3
anonymous asked Sep 17, 2015
1,407 views
Consider the given recurrence relation , find the time complexity ?T(n)=2T(n-1)+T(n-2)+C, T(0)=T(1)=1 
2 votes
2 votes
2 answers
4
Vikrant Singh asked Jan 31, 2015
1,724 views
What is the worst case time complexity to find the gcd(m,n) using best algorithm known?A. O(log(min(m,n)))B, O(log(max(m,n)))