So, basically I am having a big issue with this recurrence relationship:
$$T(n) = T(n-1)+n, T(1) = 0$$
using repeated substitution I get down to:
$$i=1, T(n-1) + n$$
$$i=2, T(n-2) + 2n - 2$$
$$i=3, T(n-3) + 3n - 3$$
$$T(n) = T(n-i) + i*n - i$$
Base case: $n-i = 1, i.e. i = n - 1$
$$T(n) = T(1) + n(n-1) - (n-1)$$
$$T(n) = n^2 - 2n + 1 $$
But, wolframalpha gives me:
$$T(n) = 0.5*n^2 + 0.5*n + c$$
And with $T(1) = 0$:
$$T(n) = 0.5*n^2 + 0.5*n - 1$$
Am I doing something wrong??
Please help!!