• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Complexity Analysis using Recurrence Relations with Answers

Question 1

What is the value of following recurrence.

T(n) = T(n/4) + T(n/2) + cn2
T(1) = c
T(0) = 0

Where c is a positive constant

  • O(n3)

  • O(n2)

  • O(n2 Logn)

  • O(nLogn)

Question 2

What is the value of following recurrence. T(n) = 5T(n/5) + [Tex]\\sqrt{n}[/Tex], T(1) = 1, T(0) = 0
  • Theta (n)
  • Theta (n^2)
  • Theta (sqrt(n))
  • Theta (nLogn)

Question 3

What is the worst case time complexity of following implementation of subset sum problem. 

C
// Returns true if there is a subset of set[] with sum equal to given sum
bool isSubsetSum(int set[], int n, int sum)
{
   // Base Cases
   if (sum == 0)
     return true;
   if (n == 0 && sum != 0)
     return false;
 
   // If last element is greater than sum, then ignore it
   if (set[n-1] > sum)
     return isSubsetSum(set, n-1, sum);
 
   /* else, check if sum can be obtained by any of the following
      (a) including the last element
      (b) excluding the last element   */
   return isSubsetSum(set, n-1, sum) || 
          isSubsetSum(set, n-1, sum-set[n-1]);
}
  • O(n * 2^n)

  • O(n^2)

  • O(n^2 * 2^n)

  • O(2^n)

Question 4

Consider the following recurrence:
gate_2006_51 Which one of the following is true?
(A) T(n) = [Tex]\\theta[/Tex](loglogn)
(B) T(n) = [Tex]\\theta[/Tex](logn)
(C) T(n) = [Tex]\\theta[/Tex](sqrt(n))
(D) T(n) = [Tex]\\theta[/Tex](n)
  • A
  • B
  • C
  • D

Question 5

The running time of an algorithm is represented by the following recurrence relation:
    if  n <= 3  then   T(n) = n
    else T(n) = T(n/3) + cn

Which one of the following represents the time complexity of the algorithm?
(A) [Tex]\\theta[/Tex](n)
(B) [Tex]\\theta[/Tex](n log n)
(C) [Tex]\\theta[/Tex](n^2)
(D) [Tex]\\theta[/Tex](n^2log n)
  • A
  • B
  • C
  • D

Question 6

The running time of the following algorithm
  Procedure A(n)  
  If n <= 2 return(1) else return A([Tex]\\lceil \\sqrt{n}  \\rceil[/Tex]);

is best described by
  • O(n)
  • O(log n)
  • O(1og log n)
  • O(1)

Question 7

What is the time complexity of the following recursive function: 
 

c
int DoSomething (int n) 
{
  if (n <= 2)
    return 1;
  else  
    return (DoSomething (floor(sqrt(n))) + n);
}

(A) [Tex]\\theta   [/Tex](n) 
(B) [Tex]\\theta   [/Tex](nlogn)
(C) [Tex]\\theta   [/Tex](logn)
(D) [Tex]\\theta   [/Tex](loglogn)
 

  • A

  • B

  • D

  • C

Question 8

The time complexity of the following C function is (assume n > 0 (GATE CS 2004) c
int recursive (mt n)
{
   if (n == 1)
     return (1);
   else
     return (recursive (n-1) + recursive (n-1));
}
  • 0(n)
  • 0(nlogn)
  • 0(n^2)
  • 0(2^n)

Question 9

Consider the following recurrence T(n) = 3T(n/5) + lgn * lgn What is the value of T(n)?
(A) [Tex]\\Theta(n ^ \\log_5{3})[/Tex]
(B) [Tex]\\Theta(n ^ \\log_3{5})[/Tex]
(c) [Tex]\\Theta(n Log n )[/Tex]
(D) [Tex]\\Theta( Log n )[/Tex]
  • A
  • B
  • C
  • D

Question 10

Consider the following recurrence. T(n) = T([Tex]\\sqrt{n}[/Tex]) + [Tex]\\Theta(Log Log n)[/Tex] What is the value of recurrence?
(A) [Tex]\\Theta( (Log Log n) ^ 2)[/Tex]
(B) [Tex]\\Theta(Log Log n)[/Tex]
(B) [Tex]\\Theta(n)[/Tex]
(B) [Tex]\\Theta(Log Log Log n)[/Tex]
  • A
  • B
  • C
  • D

There are 35 questions to complete.

Last Updated :
Take a part in the ongoing discussion