Skip to content
Official PYQ · 1997

GATE CS 1997 Q4.6 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Let T(n)T(n) be the function defined by T(1)=1, T(n)=2T(⌊n2⌋)+nT(1) =1, \: T(n) = 2T (\lfloor \frac{n}{2} \rfloor ) + \sqrt{n} for n≥2n \geq 2.

Which of the following statements is true?

Choose one option
View worked solution

Answer: B

To find the asymptotic tight bound for the recurrence relation, we can apply the Master Theorem for divide-and-conquer recurrences of the form:

T(n)=aT(nb)+f(n)T(n) = aT\left(\frac{n}{b}\right) + f(n)

For the given recurrence:

T(n)=2T(⌊n2⌋)+nT(n) = 2T\left(\left\lfloor \frac{n}{2} \right\rfloor\right) + \sqrt{n}

We identify the parameters:

  • a=2a = 2
  • b=2b = 2
  • f(n)=n=n0.5f(n) = \sqrt{n} = n^{0.5}

Now, we compare f(n)f(n) with nlog⁡ban^{\log_b a}:

nlog⁡ba=nlog⁡22=n1=nn^{\log_b a} = n^{\log_2 2} = n^1 = n

Since f(n)=O(n1−ϵ)f(n) = O(n^{1 - \epsilon}) for ϵ=0.5>0\epsilon = 0.5 > 0, we are in Case 1 of the Master Theorem.

Therefore, the solution to the recurrence is:

T(n)=Θ(nlog⁡ba)=Θ(n)T(n) = \Theta(n^{\log_b a}) = \Theta(n)

Since T(n)=Θ(n)T(n) = \Theta(n), it is also true that T(n)=O(n)T(n) = O(n).

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

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