2,483 views
0 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 1 vote
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

Position:
Show:

Related questions

1 1 vote
2 2 answers
1.2k
1.2k views
Anjana Babu asked Dec 21, 2016
1,166 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 3 votes
1 1 answer
3.5k
3.5k views
sumit_kumar asked Jun 25, 2017
3,530 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 3 votes
1 answers 1 answer
1.1k
1.1k views
sumit_kumar asked Jun 24, 2017
1,102 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 0 votes
0 0 answers
477
477 views
LavTheRawkstar asked Jan 18, 2017
477 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...