GATE | GATE CS 1999 | Question 46

If T1 = O(1), give the correct matching for the following pairs:

(M) Tn=Tn−1+n           (U) Tn=O(n)
(N) Tn=Tn/2 +n          (V) Tn=O(nlogn)
(O) Tn=Tn/2 +nlogn      (W) T=O(n^2)
(P) Tn=Tn−1 +logn       (X) Tn=O(log^2n) 

(A) M-W N-V O-U P-X
(B) M-W N-U O-X P-V
(C) M-V N-W O-X P-U
(D) M-W N-U O-V P-X


Answer:

Explanation:

(M) T(n) = T(n-1) + n = 1 + 2 + 3 + … + n = O(n^2) — choice is (W)

(N) T(n) = T(n/2) + n = O(n), using master theorem case -3, - choice is (U)

(O) T(n) = T(n/2) + nlogn = O(nlogn), using master theorem case -3, - choice is (v)

(P) T(n) = T(n-1) + logn = log 1 + log 2 + log 3 + … + log n 
         = log(1*2*3…*n) = log(n!) = nlogn = O(nlogn) - choice is (v) 

Therefore, none option matches.


Quiz of this Question



My Personal Notes arrow_drop_up

Improved By : swapnil1998



Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.