Data Structures and Algorithms - Performance Analysis of Algorithms and Recurrences

Avatto > > UGC NET COMPUTER SCIENCE > > PRACTICE QUESTIONS > > Data Structures and Algorithms > > Performance Analysis of Algorithms and Recurrences

51. What is the time complexity of the following recursive function:

  • Option : D
  • Explanation :
    The given function is recursive so the equivalent recursion equation is

    All the level sums are equal to n. The problem size at level k of the recursion tree is n2– k and we stop recursing when this value is a constant.
    Setting n2–k = 2 and solving for k gives us
    2– klog2n = 1
    2k = log2n
    k = log2 log2n
    So T(n) = θ(log2 log2n)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


52. An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is true about the number of comparisons needed?

  • Option : B
  • Explanation :
    Since,
    2n – c = average number of comparison needed.
    1.5 n – 2 = number of comparison in case.
    n log2n = also doesn't conform with number of comparison needed.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


53. Consider the following C code segment:

  • Option : B
  • Explanation :
    Upper bound may be √n times it gets executed. Lower bound may be that if gets executed only once or twice.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


54. Arrange the following functions in increasing asymptotic order:
A. n1/3
B. en
C. n7/4
D. nlog9n
E. 1.0000001n

  • Option : A
  • Explanation :
    B & E are exponential functional
    so {B, E} > {A, C, D}
    * for larger value of n E > B.
    * A < C (clearly power is less)
    * D < C for larger value of n
    So A < D < C < E < B.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


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

  • Option : A
  • Explanation :
    Given if n = 1 then T (1) = 1
    So put n = 1 in all options only option (A) gives 1
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *