Recurrence Relations for GATE

Last Updated :
Discuss
Comments

Question 1

Consider the following two recurrence relations T(n) and S(m):

sudo-gate-q6-2
sudogate-q6-1

What will be complexity of above relations?

  • O(log2n) and O(log2m) respectively

  • O(n) and O(log2m) respectively

  • O(log2n) and O(m) respectively

  • O(n) and O(m) respectively

Question 2

Which of the following recurrence relations do not represent the worst case of Quick Sort?

  • T(n) = T(n/2) + O(n)
     

  • T(n) = T(n-1) + T(0) + O(n)

  • T(n) = 2T(n/2) + O(n)

  • T(n) = 4T(n/2) + O(1)

Question 3

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

 Recursive Algorithm      Recurrence Relation 
P.Binary searchI.T(n) = T(n-k) + T(k) + cn 
Q.Merge sortII.T(n) = 2T(n-1) + 1 
R.Quick sortIII.T(n) = 2T(n/2) + cn 
S.Tower of HanoiIV.T(n) = T(n/2) + 1 

[GATE 2004]

  • P-II, Q-III, R-IV, S-I

  •  P-IV, Q-III, R-I, S-II

  • P-III, Q-II, R-IV, S-I

  • P-IV, Q-II, R-I, S-III

Question 4

Consider the following code snippet:
for i = 1 to n:
   for j = 1 to n:
       print(i, j)

What is the time complexity of this code snippet? 
 

  • O(n2)

  • O(n)

  • O(n3)


  • O(1)

Question 5

Which asymptotic notation is used to represent the average-case time complexity of an algorithm?

  • Big-O Notation ( O- Notation )

  • Theta Notation ( Θ-notation )

  • Omega Notation (Ω-notation)

  • None of the above

Question 6

Consider the recurrence relation T(n) = 2T(n/2) + n/log n. What is the time complexity of the algorithm based on this recurrence relation?

  • Θ(n)  

  • Θ(n log n)

  • Θ(n2)  

  • Θ(n log2 n)  

Question 7

What is the time complexity of an algorithm that runs in Θ(n^2) and requires 3n^2 + 5n + 7 operations?

  • Θ(n)  

  • Θ(n2)  

  • Θ(n3)

  • Θ(1)  

Question 8

You are given a recursive function f(n) that divides n by 2 at each recursive call, and then performs a constant amount of work at each level. The recurrence relation for the time complexity is:

T(n)=T(n/2)+O(1)

What is the worst-case time complexity of this function using the Master Theorem?

  • O(log n)

  • O(n)

  • O(n log n)

  • O(1)

Question 9

Consider the following recurrence relation for an algorithm’s time complexity:

T(n)=3T(n/4)+O(n)

Using the Master Theorem, what is the time complexity of the algorithm?

  • O(n log n)

  • O(n)

  • O(n2)

  • None of these

Question 10

The time complexity of an algorithm is O(2^n). If the input size doubles, approximately how much does the running time increase?

  • 2

  • n

  • 2n

  • n2

There are 10 questions to complete.

Take a part in the ongoing discussion