Which method should I use and how can I solve this recurrence to find the complexity (order) of the recurrence relation?
The equation is: $T(n) = 4T(n-1) - 3T(n-2) +1$
Find $O(T(n))$.
Which method should I use and how can I solve this recurrence to find the complexity (order) of the recurrence relation?
The equation is: $T(n) = 4T(n-1) - 3T(n-2) +1$
Find $O(T(n))$.
We have
$$T(n) - 4T(n-1) + 3T(n-2) = 1. \qquad \cdots (1)$$
We solve it like we solve differential equations, by summing a complementary function $C(n)$ and a particular solution $P(n)$, where $C$ solves the homogeneous equation
$$T(n) - 4T(n-1) + 3T(n-2) = 0, \qquad \cdots (2)$$
and $P$ is any solution to (1).
Can you continue? Do you know what is an eigenfunction to (2)?
The characteristic equation is $x^2-4+3=0$, so $(x-3)(x-1)=0$.
Thus $C(n) = A\cdot 3^n + B\cdot 1^n$, where A and B are constants, to be determined by initial data (such as T(0), T(1)).
Now, we may try to find a particular solution. We usually start by trying constants. However, constants can only solve the homogeneous equation in this case, so we proceed to try linear functions $P(n) = c\cdot n$. According to a helpful commenter Zarrax, we get $ c = -1/2$.
However, you only care about the complexity (order) of the solution. So yeah, clearly the order is $O(3^n)$