Skip to content
Related Articles

Related Articles

GATE | GATE-IT-2004 | Question 58

View Discussion
Improve Article
Save Article
  • Last Updated : 22 Jun, 2021
View Discussion
Improve Article
Save Article

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


Answer: (B)

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) + \theta(n)

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

Read More at : https://www.geeksforgeeks.org/analysis-algorithm-set-4-master-method-solving-recurrences/

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!