See title. I'm trying to apply the method from this question: Easy: Solve T(n)=T(n-1)+n by Iteration Method. What I have so far is this, but I don't know how to proceed from here on:
T(n) = T(n-1) + n2
T(n-1) = T(n-2) + (n-1)2 = T(n-2) + n2 - 2n + 1
T(n-2) = T(n-3) + (n-2)2 = T(n-3) + n2 - 4n + 4
T(n-3) = T(n-4) + (n-3)2 = T(n-4) + n2 - 6n + 9
Substituting the values of T(n-1), T(n-2) and T(n-3) into T(n) gives:
T(n) = T(n-2) + 2n2 - 2n + 1
T(n) = T(n-3) + 3n2 - 6n + 5
T(n) = T(n-4) + 4n2 - 12n + 14
Now I have to find a pattern but I don't really know how to do that. What I got is:
T(n) = T(n-k) + kn2 - ...???
If you combine the equations you yourself write: