Possible Error in Recurrence Relation Solution

71 Views Asked by At

I am trying to solve the following recurrence relation but I think there's an error in my logic or thought process. Can you please help me? Here's what I have done so far.

n >= 1 is an integer

T(1) = 1

T(n) = T(n-1) + n

My approach is below

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

T(n) = T(n-2) + n-1 = T(n-2-1) + n-1 + n -1 = T(n-3) + 2n -2

T(n) = T(n-3) + 2n -2 = T(n-4) + n-1 + 2n - 2 = T(n-4) + 3n - 3

By observation, I was came up with

T(n) = T(n-k) + Kn -k + n

Let k = n-l

Therefore

T(n) = 1 + n^2 -n -n + 1 -n = 2 + n^2 - n

However, this solution doesn't seem correct....

1

There are 1 best solutions below

0
On

There is a mistake in your first line. You wrote

$T(n) = T(n-1)+n \color{red}= T(n-1-1) + n-1= \dots$

That second equality is false. I think what you meant to write is

$T(n) = T(n-1)+n = T(n-1-1) +\color{blue}{n-1}+ n= \dots$

That is, you apply the same recursion relation to the $T(n-1)$.