Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I've solved $T(n)=2T(n/4)+\sqrt{n}$ to equal $2^{\log_{4}n}(\log_{4}n+1)$, but I'm not sure how to solve it directly.

I have:

$2(2T(\frac{n}{16})+\sqrt{\frac{n}{4}})+\sqrt{n} = 4T(\frac{n}{16})+2\sqrt{n}$

$2(4T(\frac{n}{64})+2\sqrt{\frac{n}{16}})+\sqrt{n} = 8T(\frac{n}{64})+2\sqrt{n}$

$2(8T(\frac{n}{256})+2\sqrt{\frac{n}{64}})+\sqrt{n}=16T(\frac{n}{256})+\frac{5}{4}\sqrt{n}$

I'm not seeing a pattern here and I'm not sure I'm modifying $n$ as necessary. What's the problem?

share|improve this question
    
Hey you can use the master theorem and it's easier!!! –  richard clare Mar 15 at 17:33
add comment

1 Answer

up vote 3 down vote accepted

Let's turn the equation $T(n) = 2 T(n/4) + \sqrt{n}$ into a recurrence equation. To this end, let $f(m) = T(4^m p)$ for some $p>0$. Then $$ f(m) = 2 f(m-1) + \sqrt{p} 2^m $$ which can be systematically solved. First rewrite it as $$ 2^{-m} f(m) - 2^{-(m-1)} f(m-1) = \sqrt{p} $$ Then sum equations from $m=1$ to some upper bound $k$: $$ \sum_{m=1}^k \left(2^{-m} f(m) - 2^{-(m-1)} f(m-1) \right) = \sum_{k=1}^m \sqrt{p} $$ The sum on the left-hand-side telescopes: $$\begin{eqnarray} \sum_{m=1}^k \left(2^{-m} f(m) - 2^{-(m-1)} f(m-1) \right) &=& \left(2^{-m} f(m) - \color\green{2^{-(m-1)} f(m-1)}\right) + \\ &\phantom{=}& \left(\color\green{2^{-(m-1)} f(m-1)} - 2^{-(m-2)} f(m-2)\right) + \\ &\phantom{=}& \vdots \\ &\phantom{=}& \left( 2^{-2} f(2) - \color\green{2^{-1} f(1)} \right) +\\ &\phantom{=}& \left( \color\green{2^{-1} f(1)} - 2^{-0} f(0) \right) \\ &=& 2^{-m} f(m) - f(0) \end{eqnarray} $$ Hence we arrive at the solution $$ f(m) = 2^m \left( m \sqrt{p} + f(0) \right) $$ since $m = \log_4 \left(\frac{n}{p}\right)$ we get: $$ T(n) = \sqrt{\frac{n}{p}} \left( \sqrt{p} \cdot \log_4 \frac{n}{p} + f(0)\right) = \sqrt{n} \log_4(n) + d \sqrt{n} $$ where $d$ is a free constant to be determined by the initial condition.

share|improve this answer
    
I'm afraid I don't understand the steps involved here, but I really appreciate the effort and have upvoted the answer. Could you please add a beginner-level version using the approach in the OP? –  mirai Oct 20 '12 at 3:09
    
@miray I have filled in the solution in more details. Please let me know if it still remains unclear. –  Sasha Oct 20 '12 at 3:20
    
Thanks, I really appreciate it. –  mirai Oct 20 '12 at 16:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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