1,577 views
0 votes
0 votes

What is the time complexity of the following code snippet? Assume "statement" takes $O(1)$ time.

int x=0;
int A(n)
{

   statement;
   if(n==1)return 1;
   
   else
   {
     x + = 4A(n/2)+n^{2}
      
      return (x);
    }

}

$A)\theta(n^{2}logn)$             $B)\theta(logn)$                $C)\theta(n^{2})$                $D)\theta(nlogn)$

1 Answer

1 votes
1 votes
4A(n/2) numerical multiplication takes O(1) time

so recurrence relation 

A(n) = A(n/2) + O(1) + O(1)

a = 1 , b = 2 , k = 0 

bk = 20 = 1

a = b

p = 0 > -1

A(n) = θ(n logba* logn)

        = θ(logn)

Correct answer = B

Related questions

1 votes
1 votes
2 answers
1
Anjana Babu asked Dec 21, 2016
542 views
Write C Program using Recursive Funtions for the Problem Described below and Analyse the Complexity Of the CodeProblemGiven an unordered array arr[] which contains n di...
3 votes
3 votes
1 answer
2
sumit_kumar asked Jun 25, 2017
3,146 views
what is time comlexity procedure for following recursive equation by substitution method:T(n)= T(n-1)+T(n-2) , if n>=2 =1 , if n=1; =0 , if n=0.
3 votes
3 votes
1 answer
3
sumit_kumar asked Jun 24, 2017
740 views
How to apply back substiution method on following recursive equation to find time complexity:T(n)= 2 T(n/2) + (n/log n) , where "n" is input.
0 votes
0 votes
0 answers
4
LavTheRawkstar asked Jan 18, 2017
272 views
How to calculate the recurrence relation for Recursive Fibonicci series using the substitution method .How to guess and how to start and finally how to evaluate the tim...