GATE | GATE CS 1996 | Question 37
The recurrence relation
T(1) = 2
T(n) = 3T(n/4)+n
has the solution, T(n) equals to
(A)
O(n)
(B)
O(log n)
(C)
O(n^3/4)
(D)
None of the above
Answer: (A)
Explanation:
As the recurrence equation is given:
= 3 (3t(n/4^2)+ n/4) +n
= 3^2t(n/4^2 ) + n(1+3/4)
= 3^2(3t(n/4^3) +n/4^2) + n(1+3/4)
= 3^3t(n/4^3 ) + n(1+3/4 + 3^2/4^2)
= 3^it(n/4^i) + n(1+3/4 + 3^2/4^2 + ……..+3^(i-1)/4^(i-1))
we will stop at i = log4n, n/4^i = 1
Therefore,
t(n) = 3^ log4nt(1) +n . Σ(k-= to log4 n-1) (3/4)^k
<= 3log4n. Θ(1) + n Σ( k= 0 to infinity) (3/4)^k = Θn^log4(3)+4n = o(n)+4n
t(n) = O(n)
Quiz of this Question
Please comment below if you find anything wrong in the above post
Last Updated :
01 Nov, 2017
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...