edited by
2,137 views
3 votes
3 votes

Consider the following recurrence relation:

$T(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. $T(n)=\Theta(n \log \log n)$
  2. $T(n)=\Theta(n \log n)$
  3. $T(n)=\Theta\left(n^2 \log n\right)$
  4. $T(n)=\Theta\left(n^2 \log \log n\right)$

edited by

3 Answers

3 votes
3 votes


Answer will be $option$ $A$.

2 votes
2 votes

$$\begin{align}
T(n) &= \sqrt{n}T(\sqrt{n}) + n \\
\frac{T(n)}{n}&= \frac{T(\sqrt{n})}{\sqrt{n}} + 1 \\
S(n) &= S(\sqrt{n}) + 1 \tag{S(n) = T(n)/n}\\
S(2^k) &= S(2^{k/2}) + 1 \tag{n = 2^k}\\
Q(k) &= Q(k/2) + 1 \\
Q(k) &= \theta(\log k) \tag{Masters' theorem} \\
\implies S(2^k) &= \theta(\log k) \\
\implies S(n) &= \theta(\log \log n) \\
\implies T(n) &= \theta(n\log \log n) \\
\end{align}$$

$\textbf{Option (A) is correct}$


$\underline{\textbf{Clarification over solution to }Q(k)}$

Let $F(n) = aF(\frac{n}{b}) + f(n)$; $F(1) = c$

where $a\ge 1$, $b \ge 2$, $c>0$, If $f(n) \in \theta(n^d)$ where $d\ge 0$, then

$$F(n) = \begin{cases}\theta(n^{\log_ba}) & \text{ if } f(n) \in \mathcal{O}(n^{\log_ba-\epsilon}) & \text{ for  }\epsilon>0 \\ \theta(n^{\log_ba}\log^{k+1}n) & \text{ if } f(n) \in \mathcal{O}(n^{\log_ba}\log^kn) &\text{ for  } k \ge 0 \\ \theta(f(n)) & \text{ if } f(n) \in \mathcal{\Omega}(n^{\log_ba+\epsilon}) & \text{ for  }\epsilon>0 \end{cases}$$

$Q(k) = Q(\frac{k}{2}) + 1$ shows that $a=1, b=2, d=0$

 $\log_ba = 0$, hence $k^0 \cancel \in \mathcal{O}(k^{-\epsilon})$, and $k^0 \cancel \in \mathcal{\Omega}(k^{\epsilon})$, but $k^0 \in \mathcal{O}(k^0\log^{0}k)$ $\implies Q(k) = \theta(k^0\log^{0+1}k) = \theta(\log k)$  

edited by
Answer:

Related questions

1 votes
1 votes
1 answer
2
Arjun asked Feb 16
2,363 views
​​​​​An array $[82,101,90,11,111,75,33,131,44,93]$ is heapified. Which one of the following options represents the first three elements in the heapified array?$...
1 votes
1 votes
2 answers
4
Arjun asked Feb 16
1,894 views
The number of edges present in the forest generated by the $\text{DFS}$ traversal of an undirected graph $G$ with $100$ vertices is $40$. The number of connected componen...