Thursday, July 4, 2024
HomeData ModellingData Structure & AlgorithmAlgorithms | Analysis of Algorithms (Recurrences) | Question 11

Algorithms | Analysis of Algorithms (Recurrences) | Question 11

Consider the following recurrence:

gate_2006_51

Which one of the following is true?

(A) T(n) = \theta(loglogn)
(B) T(n) = \theta(logn)
(C) T(n) = \theta(sqrt(n))
(D) T(n) = \theta(n)

(A) A
(B) B
(C) C
(D) D

Answer: (B)
Explanation: This question can be solved by first change of variable and then Master Method.

  Let n = 2^m
  T(2^m) = T(2^(m/2)) + 1
  Let T(2^m) =  S(m)
  S(m)  = 2S(m/2) + 1  

Above expression is a binary tree traversal recursion whose time complexity is \theta(m). You can also prove using Master theorem.

S(m)  = \theta(m)  
      = \theta(logn)  /* Since n = 2^m */

Now, let us go back to the original recursive function T(n)

  T(n)  = T(2^m) = S(m)
                 = \theta(Logn)

Quiz of this Question

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha Wardslaus
Dominic Rubhabha Wardslaushttps://neveropen.dev
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments