1
$\begingroup$

This question already has an answer here:

$$ T(n)=\sqrt{n}T(\sqrt{n})+n $$

$$T(1)=T(2)=1$$

the answer is given as $$ \Theta(n\log \log n) $$ I tried to draw recursion tree, it got all crazy

I tried using substitution method instead $$\sqrt{n}=2^{m}$$ $$T(2^{m})=2^{m/2}T(2^{m})+2^{m}$$ $$S(m)=\frac{m}{2}S(m)+m$$ $$\frac{S(m)}{m}=\frac{1}{2}S(m)+1$$ am I right?

$\endgroup$

marked as duplicate by Raphael Sep 15 '14 at 10:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    $\begingroup$ Your question already includes a complete answer to the original problem but no question about this answer. Thus, only "yes/no" answers may remain, helping neither you nor future visitors. Please read related meta discussions here and here and adjust your question accordingly, e.g. by formulating a specific question about a single element of your answer you are uncertain about. If you just want general feedback, you are welcome to visit us in Computer Science Chat. $\endgroup$ – Wandering Logic Sep 13 '14 at 15:57
  • $\begingroup$ @WanderingLogic Note that a user with only 4 rep across all of SE can't actually use chat. $\endgroup$ – David Richerby Sep 13 '14 at 16:33
  • $\begingroup$ @D.W. It's an interesting point: the question is indeed a duplicate, but none of the answers in the duplicate address the method the OP wanted (which is why I added an answer here). $\endgroup$ – Rick Decker Sep 13 '14 at 20:06
  • 1
    $\begingroup$ @RickDecker, Yes, but here's my reasoning. "Check my answer" questions are not appropriate for this site, as Wandering Logic explained. Therefore, for this question to be appropriate for this site, it needs to be turned into a "how do I solve this recurrence" rather than a "check my answer" -- and then it's a straight-up duplicate. (I don't see anything in the question that says the OP insists it has to be solved using a particular method, just that the OP wants us to check his answer.) $\endgroup$ – D.W. Sep 13 '14 at 20:09
  • 1
    $\begingroup$ @D.W. Though I don't completely agree with a blanket restriction against "Check my answer" posts, that's just my opinion. Suppose, though, that the OP had said something along the lines of "Here's my attempt at at using substitution ... $S(m)=(2m)/(m+2)$ which doesn't seem at all right. Can anybody point out where I went awry?" That would have been a post where the OP demonstrated some effort, which is what we want. Would such a post have gotten a better reception? $\endgroup$ – Rick Decker Sep 13 '14 at 20:17
1
$\begingroup$

In the second line of your solution, you shouldn't have two terms $T(2^m)$. Here's a correct derivation: $$\begin{align} T(n) &= \sqrt{n}\ T(\sqrt{n}) + n & \text{so, dividing by $n$ we get}\\ \frac{T(n)}{n} &= \frac{T(\sqrt{n})}{\sqrt{n}} + 1 &\text{and letting $n = 2^m$ we have}\\ \frac{T(2^m)}{2^m} &= \frac{T(2^{m/2})}{2^{m/2}} + 1 \end{align}$$ Now let $$\begin{align} S(m) &= \frac{T(2^m)}{2^m} & \text{so our original recurrence becomes}\\ S(m) &= S(m/2)+1 \end{align}$$ which is a well-known recurrence with solution $$ S(m)=\Theta(\lg m) $$ Returning to $T()$ we then have, with $n=2^m$ (and $m=\lg n$), $$ \frac{T(n)}{n} = \Theta(\lg\,\lg n) $$ So $T(n) =\Theta(n\,\lg\,\lg n)$.

This has been asked before: Solving a recurrence relation with √n as parameter, though this particular substitution solution wasn't included among the answers

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.