I'm trying to find the recurrence of $$ T(n) = T (n-1) + n^2$$
After following the steps, $$T (n) = T (n-1) + n^2 = T (n-2) + (n-1)^2 + n^2 $$ $$T (n) = T (n-2) + (n-1)^2 + n^2 = T(n-3) + (n-3)^2 + (n-1)^2 + n^2 $$ $$T (n) = T (n-3) + (n-3)^2 + (n-1)^2 + n^2 =T (n-4) + (n-4)^2 + (n-3)^2 + (n-1)^2 + n^2 $$ i generalize recurrence relation at the kth step of the recursion, which is
$$ T(n) = T (n-k) + \sum^n_{k=0} (n-k)^2$$
Just wondering,
What is the summation of $$\sum^n_{k=0} (n-k)^2$$
is it the same as $$ n(n+1)(2n+1)/6$$
?
$$\sum^n_{k=0} (n-k)^2=n^2+(n-1)^2+\cdots + 0^2= 0^2+1^2+\cdots +n^2 =\sum^n_{k=0} k^2=\frac16n(n+1)(2n+1).$$