Top MCQs on Complexity Analysis using Recurrence Relations with Answers

Last Updated :
Discuss
Comments

Question 1

What is the time complexity for the following C module? Assume that n>0 . int module(int n) { if (n == 1) return 1; else return (n + module(n-1)); }

  • O(n)

  • O(log n)

  • O(n2)

  • O(n!)

Question 2

Consider the recurrence relation a1 = 8, an = 6n2 + 2n + an-1. Let a99 = k x 104. The value of K is _____

 
Note : This question was asked as Numerical Answer Type.

  • 190

  • 296

  • 198

  • 200

Question 3

The given diagram shows the flowchart for a recursive function A(n). Assume that all statements, except for the recursive calls, have O(1) time complexity. If the worst case time complexity of this function is O(nα), then the least possible value (accurate up to two decimal positions) of α is __________
z9

  • 2.2 to 2.4

  • 3.2 to 3.4

  • 0 to 1.8

  • 1

Question 4

When n = 22k for some k ≥ 0, the recurrence relation
T(n) = √(2) T(n/2) + √n, T(1) = 1
evaluates to :

  • √(n) (log n + 1)

  • √(n) (log n )

  • √(n) log √(n)

  • n log √(n)

Question 5

Let T(n) be the function defined by T(1)= 1, T(n)= 2T (⌊n/2⌋) + √n  for n≥2. Which of the following statement(s) is true? a.  T(n) = O(√n) b.  T(n) = O(n) c.  T(n) = O(log n) d. None of the above

  • a
  • b
  • c
  • d

Question 6

Consider the following function
Function F (n, m: integer): integer;
begin
    If (n<=0) or (m<=0) then F:=1
    else
      F:= F(n-1,m) + F(n, m-1);
    end;
Use the recurrence relation to answer the following question. asdf         Assume that n, m are positive integers. Write only the answers without any explanation. a. What is the value of F(n,2)? b. What is the value of (n,m)? c. How many recursive calls are made to the function F, including the original call, when evaluating F(n,m).

    Question 7

    The recurrence relation

     T(1) = 2
     T(n) = 3T(n/4)+n
    

    has the solution, T(n) equals to

    • O(n)

    • O(log n)

    • O(n^3/4)

    • None of the above

    Question 8

    Match the following and choose the correct answer in the order A, B, C

    A. Heap Constructionp. O(n log n)
    B. Hash table construction with linear probingq. O(n2)
    C. AVL Tree constructionr. O(n)

    (Bounds given may or may not be asymptotically tight)

    • q, r, p

    • p, q, r

    • q, p, r

    • r, q, p

    Question 9

    Consider the following recurrence: T(n) = 2T(n1/2) + 1 T(1) = 1 Which of the following is true?

    • T(n)= O(log log n)

    • T(n) = O(log n)

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

    • T(n)= O(n)

    Question 10

    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 AlgorithmRecurrence 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
    • 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

    There are 35 questions to complete.

    Take a part in the ongoing discussion