Skip to main content

GATE CSE 2024Algorithms › Recursion & Recurrence RelationsVerified

GATE CSE 2024 PYQ: Consider the following recurrence relation: T ( n ) = { n T ( n ) + n for n ≥ 1 , 1 for n = 1…

Consider the following recurrence relation:

T(n)={nT(n)+n for n≥1,1 for n=1T(n)=\left\{\begin{array}{c}\sqrt{n} T(\sqrt{n})+n \text { for } n \geq 1, \\ 1 \quad \text { for } n=1\end{array}\right.

Which one of the following options is CORRECT?

 

  1. A
    T(n)=Θ(nlog⁡log⁡n)T(n)=\Theta(n \log \log n)
    Correct answer
  2. B
    T(n)=Θ(nlog⁡n)T(n)=\Theta(n \log n)
  3. C
    T(n)=Θ(n2log⁡n)T(n)=\Theta\left(n^2 \log n\right)
  4. D
    T(n)=Θ(n2log⁡log⁡n)T(n)=\Theta\left(n^2 \log \log n\right)

Answer

(A) T ( n ) = Θ ( n log ⁡ log ⁡ n ) T(n)=\Theta(n \log \log n) T ( n ) = Θ ( n lo g lo g n )

Approach

The recurrence $T(n)=\sqrt{n}\,T(\sqrt{n})+n$ is not in standard constant-coefficient divide-and-conquer form, so normalize by dividing throughout by $n$. This converts the multiplicative factor $\sqrt{n}$ into an additive 1, yielding a simpler recurrence whose depth determines the cost.

Dividing the recurrence by $n$ gives $S(n)=S(\sqrt{n})+1$, and the substitution $n=2^{k}$ yields $Q(k)=Q(k/2)+1=\Theta(\log k)$. Hence $S(n)=\Theta(\log\log n)$ and $T(n)=\Theta(n\log\log n)$, i.e. option A.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.