I have the following recursion function:
$T(1) = 0$
$T(n) = T(n-2) + 3$
where n is odd integers
I know the closed form of this is:
$T(n) = \frac{3n-3}{2}$ but this was purly by guessing.
Is it possible to show how you can derive the close form?
I have the following recursion function:
$T(1) = 0$
$T(n) = T(n-2) + 3$
where n is odd integers
I know the closed form of this is:
$T(n) = \frac{3n-3}{2}$ but this was purly by guessing.
Is it possible to show how you can derive the close form?
We have $T(n)=T(n-2)+3$
Setting $T(n)=S(n)+an+b,$
$S(n)+an+b=S(n-2)+a(n-2)+b+3\iff S(n)=S(n-2)+3-2a$
Set $2a=3$ to find $S(n)=S(n-2)=\cdots=S(1)=T(1)-a-b=0-\dfrac32-b$
$T(n)=\left(-\dfrac32-b\right)+\dfrac32n+b=\dfrac{3n-3}2$