I'm trying to solve the following recurrence without using the Master Theorem:
$$T(1)=1;$$
$$T(n)=3T(n/3) + 3$$
My attempt:
$T(n) = 3T(n/3) + 3$
$ = 3(3T(n/9) n/3)) + 3)$
$ = 9T(n/9) + 9$
$ = 9(3T(n/27 + n/9)) +9$
$ = 27T(n/27) + 9$
$ ...$
I know this is wrong but I'm stuck here. Thanks.
Writing out the first few terms, we get:
$$T(1) =1, T(3) = 6, T(9) = 21, T(27) = 66, T(81) = 201$$
Using this, we can see that $T(n) \approx2n$, so we make the ansatz that $T(n) = an + b$
Applying this to the recurrence relation gives us: $$\begin{align*}an + b &= 3\left(a\frac{n}{3} + b\right) + 3\\an + b &= an + 3b + 3\\2b &= -3\\b &= \frac{-3}{2}\end{align*}$$
Finally, applying the boundary condition $T(1) = 1$: $$\begin{align*}a + b &= 1\\a -\frac{3}{2} &= 1\\a &= \frac{5}{2}\end{align*}$$
Hence:
$$T(n) = \frac{5}{2}n - \frac{3}{2}$$