Help solving a recursion function T(n) = T(n-2) +3

1.1k Views Asked by At

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?

2

There are 2 best solutions below

4
On BEST ANSWER

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$

1
On

Setting $n=2m+1, n-2=2m-1=2(m-1)-1,T(2m+1)=S(m),$

$S(m)-S(m-1)=3, S(0)=T(1)=0$

So, $S(m)$ is the $(m+1)$th term of an Arithmetic Progression with $S(0)=0,$ common difference $=3$

$\implies S(m)=S(0)+(m+1-1)\cdot 3=3m=3\cdot\dfrac{n-1}2$

But $S(m)=T(2m+1)=T(n)$