# GATE | GATE-IT-2004 | Question 58

• Last Updated : 22 Jun, 2021

Consider a list of recursive algorithms and a list of recurrence relations as shown below. Each recurrence relation corresponds to exactly one algorithm and is used to derive the time complexity of the algorithm.

Recursive Algorithm Recurrence Relation
P. Binary search I. T(n) = T(n-k) + T(k) + cn
Q. Merge sort II. T(n) = 2T(n-1) + 1
R. Quick sort III. T(n) = 2T(n/2) + cn
S. Tower of Hanoi IV. T(n) = T(n/2) + 1

(A) P-II, Q-III, R-IV, S-I
(B) P-IV, Q-III, R-I, S-II
(C) P-III, Q-II, R-IV, S-I
(D) P-IV, Q-II, R-I, S-III

Explanation: These are examples of some standard algorithms whose
Merge Sort:    T(n) = 2T(n/2) + Θ(n). It falls in case 2 as c is 1 and Logba] is also 1 and  the solution is Θ(n Logn) //time complexity can be evaluated using Master Method

Binary Search: T(n) = T(n/2) + Θ(1). It also falls in case 2 as c is 0 and Logba is also 0 and the solution is Θ(Logn) //time complexity can be evaluated using Master Method

Quick Sort : Time taken by QuickSort in general can be written as  T(n) = T(k) + T(n-k-1) + (n)

Tower of Hanoi : T(n) = 2T(n-1) + 1

My Personal Notes arrow_drop_up
Recommended Articles
Page :