edited by
5,969 views
22 votes
22 votes

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.

$$\begin{array}{|l|l|l|l|}\hline \text{}  &  \textbf{Recursive Algorithm } & \text{} & \textbf{Recurrence Relation} \\\hline  \text{P} & \text{Binary search} & \text{l.} & \text{$T(n) = T(n-k) +T(k) +cn$} \\\hline  \text{Q.} & \text{Merge sort} &\text{ll.}  &  \text{$T(n) = 2T(n-1) + 1$ }\\\hline\text{R.}  &  \text{Quick sort}& \text{lll.}  &  \text{$T(n) = 2T(n/2) + cn$}\\\hline \text{S.}  &  \text{Tower of Hanoi} & \text{lV.}  &  \text{$T(n) = T(n/2) + 1$} \\\hline \end{array}$$

Which of the following is the correct match between the algorithms and their recurrence relations?

  1. $\text{P-II, Q-III, R-IV, S-I}$
  2. $\text{P-IV, Q-III, R-I, S-II}$
  3. $\text{P-III, Q-II, R-IV, S-I}$
  4. $\text{P-IV, Q-II, R-I, S-III}$
edited by

5 Answers

0 votes
0 votes
$$\begin{array}{|l|l|l|l|}\hline \text{}  &  \textbf{Recursive Algorithm } & \text{} & \textbf{Recurrence Relation} \\\hline  \text{P} & \text{Binary search} & \text{IV.} &  T(n) = T(n/2) + 1 \\\hline  \text{Q.} & \text{Merge sort} & \text{llI.}  & T(n) = 2T(n/2) + cn \\\hline\text{R.}  &  \text{Quick sort}& \text{I.}  & T(n) = T(n-k) +T(k) +cn \\\hline \text{S.}  &  \text{Tower of Hanoi} & \text{lI.}  & T(n) = 2T(n-1) + 1  \\\hline \end{array}$$
$\therefore P – IV, Q – III, R – I, S – II$

So, the correct answer is $(B).$
Answer:

Related questions

41 votes
41 votes
1 answer
5
Ishrat Jahan asked Nov 2, 2014
5,636 views
Let $H_1, H_2, H_3,$ ... be harmonic numbers. Then, for $n \in Z^+$, $\sum_{j=1}^{n} H_j$ can be expressed as$nH_{n+1} - (n + 1)$$(n + 1)H_n - n$$nH_n - n$$(n + 1) H_{n+...