I'm trying to practice recurrence equations, so I'm trying to solve this typology by unfolding method. I was wondering if what I write below was correct and obviously the result:
$T(n) = n^2 + T(n-4) = n^2 + [n^2 + T(n - 8)] = n^2 + n^2 +[n^2 + T(n-12)] = n^2 + n^2 + n^2 + [n^2 + T(n-16)] = ...$
In general we can say that $T(n)$ is done in the following way:
$$T(n) = \sum_{i=0}^{\frac{n-5}{4}} n^2 + T(n-(4+4i))$$
Note that the summation takes that form because $T(n-(4+4i)) = T(1) = 1$ when $( −(4+4) ) = 1$ which occurs for $i = \frac{n-5}{4}$
So it would be more correct to write T(n) as follows:
$$T(n) = \sum_{i=0}^{\frac{n-5}{4}} n^2 + 1 $$
At this point we leave out the constant 1 (which asymptotically is irrelevant) and focus on the summation :
$$T(n) = \sum_{i=0}^{\frac{n-5}{4}} n^2 = n^2\sum_{i=0}^{\frac{n-5}{4}} 1 = n^2 ( \frac{n-5}{4} +1) = O(n^3)$$
So overall we can say that :
$$T(n) = O(n^3)$$
The second line is also wrong. How do you know $\frac{n-5}4$ is an integer? For example, if $n=6$, then $\frac{n-5}4=\frac14$, which doesn't make sense.
What is your initial condition?
In general, we can solve it by setting $n=4k, n=4k+1, n=4k+2, n=4k+3$ and solve each case separately. Since the @Cesareo's comment has shown the $n=4k$ case, I will show the $n=4k+1$ case. The rest two cases can be solved similarly. Now, let $n=4k+1$ and $P_k=T(4k+1)$, we get
$T(4k+1)=T(4k-3)+(4k+1)^2\Longleftrightarrow P_k=P_{{k-1}}+16k^2+8k+1$
Take the sum
$$\sum_{m=1}^k P_m-P_{{m-1}}=\sum_{m=1}^k16m^2+8m+1\Longrightarrow P_k-P_0=\frac83k(k+1)(2k+1)+4k(k+1)+k$$
Simplify and we get
$$P_k=P_0+\frac13 k\cdot ( 16 k^2 + 36 k+23 )$$
Therefore,
$$\boxed{T(4k+1)=\frac{16}3 k^3 + 12 k^2+\frac{23}3k +T_1}$$
The rest two cases $T(4k+2)$ and $T(4k+3)$ can be solved similarly.