Consider the recurrence relation: Where b and c are constants. The order of the algorithm corresponding to above recurrence relation is:
(A)
n
(B)
n2
(C)
n log n
(D)
n3
Answer: (D)
Explanation:
We can use Master theorem to solve this recurrence relation:
T(n) = aT(n/2) + Θ(nklogpn) In given question: T(n) = 8T(n/2) + Cn here a = 8 and b = 2 and k = 1. clearly a > bk So T(n) = Θ(nlogba ) T(n) = Θ(nlog2 8) ie T(n) = Θ(n3)
So, option (D) is correct.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :
Recommended Articles