0
$\begingroup$

$T(1) = 2$

$T(n) = T(n-1) + n/2$

My guess is this would be equivalent to $T(n) = 2 + \sum\limits_{i=2}^n \frac{n}{2^{i-1}}$. However, I don't know how to advance from here.

$\endgroup$
1
$\begingroup$

HINT Note that $$ \begin{split} T(n) &= T(n-1) + \frac{n}{2} \\ &= T(n-2) + \frac{n-1}{2} + \frac{n}{2} \\ &= \ldots \\ &= T(n-n) + \sum_{k=1}^n \frac{k}{2} \\ &= T(0) + \frac{1}{2} \sum_{k=1}^n k \end{split} $$

$\endgroup$
  • 2
    $\begingroup$ You seem to be operating under the impression that the OP's guess was correct. Have you checked that? $\endgroup$ – JMoravitz Aug 3 '16 at 4:08
  • $\begingroup$ @JMoravitz fixed, thank you $\endgroup$ – gt6989b Aug 3 '16 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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