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 been working on a problem set for a bit now and I seem to have gotten the master method down for recurrence examples. However, I find myself having difficulties with other methods (recurrence trees, substitution). here is the question I am stuck on: $$T(n) = T(n-2) + n^2$$ Is there a pattern as follows? $$n^2 + T(n-2) + T(n-4) +...$$ where it goes until there is no more n left. so around n/2 times and would that mean that $$n^2 + (n-2)^2 + (n-i) ^2$$ so the asymptotic bound would be $\theta(n^2)$?

I am honestly taking a shot in the dark here, so I was hoping someone could help guide me in how to approach these questions.

Thank you,


share|improve this question
perhaps an indirect answer would even do, something to show how to solve questions of form t(n-i) + f(n) –  Tyler Feb 5 '13 at 9:31

2 Answers 2

$$T(n) = T(n-2) + n^2 = T(n-4) + (n-2)^2 + n^2 = T(n-2k) + \sum\limits_{i = 0}^{k - 1}(n - 2i)^2$$

This goes down till $n - 2k \ge 0$. Assuming even $n$ (for asymptotic complexity, it does not really matter, and you can do similar calculations for odd $n$ also, with the same asymptotic results), we have $k = \frac{n}{2}$ at the end.

$$T(n) = T(0) + \sum\limits_{i = 0}^{\frac{n}{2} - 1}(n - 2i)^2 = \sum\limits_{i = 0}^{\frac{n}{2} - 1}(n^2 - 4ni + 4i^2) + C$$ $$T(n) = n^2\cdot\left(\frac{n}{2}-1\right) - 4n\cdot\frac{1}{2}\cdot\frac{n}{2}\cdot\left(\frac{n}{2} - 1\right) + 4\cdot\frac{1}{6}\cdot\left(\frac{n}{2} - 1\right)\cdot\frac{n}{2}\cdot n + C$$ $$\therefore \ T(n) = \Theta(n^3)$$

share|improve this answer

Note that if $n=2k$ is even, then $$ T(n)+T(n-1) = n^2+(n-1)^2+ \cdots+4^2+3^2 + T(2)+T(1) =\frac{n(n+1)(2n+1)}{6} + C. $$ Here $C=T(2)+T(1) -2^2-1^2$ and we used the formula $\sum_{i=0}^n i^2 = \frac{n(n+1)(2n+1)}{6}$. We also note that $T(n) \sim T(n-1)$, so we may conclude that $$ T(n) \sim n^3/12. $$

share|improve this answer

Your Answer


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.