Skip to content
Official PYQ · 2006

GATE CS 2006 Q51 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Consider the following recurrence:

T(n)=2T(n)+1,T(n)=2T\left ( \sqrt{n}\right )+1, T(1)=1T(1)=1

Which one of the following is true?

Choose one option
View worked solution

Answer: B

To solve the recurrence relation T(n)=2T(n)+1T(n) = 2T(\sqrt{n}) + 1, we can use the change of variables method.

Let n=2mn = 2^m, which implies m=log⁡2nm = \log_2 n.

Substituting this into the recurrence:

T(2m)=2T(2m/2)+1T(2^m) = 2T(2^{m/2}) + 1

Now, let S(m)=T(2m)S(m) = T(2^m). The recurrence relation can be rewritten as:

S(m)=2S(m/2)+1S(m) = 2S(m/2) + 1

We can solve this new recurrence using the Master Theorem for divide-and-conquer recurrences of the form S(m)=aS(m/b)+f(m)S(m) = aS(m/b) + f(m):

  • Here, a=2a = 2, b=2b = 2, and f(m)=1f(m) = 1.
  • Compare f(m)f(m) with mlog⁡ba=mlog⁡22=m1=mm^{\log_b a} = m^{\log_2 2} = m^1 = m.
  • Since f(m)=O(m1−ϵ)f(m) = O(m^{1-\epsilon}) for any ϵ>0\epsilon > 0, we fall into Case 1 of the Master Theorem.

Therefore, the solution for S(m)S(m) is:

S(m)=Θ(m)S(m) = \Theta(m)

Substituting back m=log⁡2nm = \log_2 n:

T(n)=Θ(log⁡n)T(n) = \Theta(\log n)

Thus, the correct option is B.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Asymptotic Worst Case Time and Space Complexity questions