I am not able to understand Q1, Q6, Q9 and Q13 of the pdf. please help me to understand the concept
Complexity Analysis MCQs
Hello @krikhi,
Ques 1:
You would understand this after studying graphs.
Ques 6:
the answer is O(n)
Ques 9:
the answer is O(log n)
int power(int 2, unsigned int n)
{
int temp;
if( n == 0)
return 1;
temp = power(2, n/2);
if (n%2 == 0)
return temp*temp;
else
return 2*temp*temp;
}
Ques 13:
You can use master’s theorem:
T(n) = aT(n/b) + f(n) where a >= 1 and b > 1
There are following three cases:
-
If f(n) = Θ(n^c) where c < Logb(a) then T(n) = Θ(nLogba)
-
If f(n) = Θ(n^c) where c = Logb(a) then T(n) = Θ((n^c)*(Log n))
-
If f(n) = Θ(n^c) where c > Logb(a) then T(n) = Θ(f(n))
using case 2:
The answer is Θ(nlogn)
Hope, this would help.
Give a like if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
I am not able to understand the master theorem. please help me to get the concept.