PA of Algorithms Q51

0. 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 *