How can I solve the following recurrence without using the master theorem?
$T(n)= 4T(n/2)-1$ for $n>4$ and $T(n)=5$ for $n\le 4$, $n$ is a power of $2$.
How can I solve the following recurrence without using the master theorem?
$T(n)= 4T(n/2)-1$ for $n>4$ and $T(n)=5$ for $n\le 4$, $n$ is a power of $2$.
The idea is to convert this recurrence to the simpler recurrence $$ S(n) = 4S(n/2). $$ How do we do this? Let $S(n) = T(n) + f(n)$. Since $$ S(n) = T(n) + f(n) = 4T(n/2) - 1 + f(n) = 4S(n/2) - 4f(n/2) - 1 + f(n), $$ we need that $$ f(n) = 4f(n/2) + 1. $$ Luckily, $f(n) = -1/3$ is a solution. So $S(n) = T(n) - 1/3$ satisfies $$ S(n) = 4S(n/2), \qquad S(4) = 14/3. $$ You take it from here.
You can use a change of domain here:
$$T(n) = \begin{cases} 5 & n \leq 4\\ 4T(n/2) - 1 & n > 4\\ \end{cases}$$
Assume $n = 2^{k}$, then let $S(k) = T(2^k)$ and we have:
$$S(k) = \begin{cases} 5 & k \leq 2 \quad \text{because }2^2 = 4\\ 4S(k-1) - 1 & k > 2\\ \end{cases}$$
Now we can turn this into a sum because $k$ is decreasing by 1 each time:
$$\begin{align*} S(k) &= 5 + \sum_{i = 3}^k -1 \cdot 4^{k - i}\\ &= 5 - \sum_{i = 3}^k 4^{k - i}\\ &= 5 - \sum_{i = 0}^{k-3} 4^i\\ &= 5 - (4^{k-2} - 1)/3\\ \end{align*}$$
Now we can plug $n$ back in with $k = \log_2 n$:
$$\begin{align*} T(n) &= S(\log_2 n)\\ &= 5 - (4^{\log_2 n - 2} - 1)/3\\ &= 5 - (4^{\log_2 n}/16 - 1)/3\\ &= 5 - (2^{2\log_2 n}/16 - 1)/3\\ &= 5 - (n^2/16 - 1)/3\\ &= 16/3 - n^2 / 48 \end{align*}$$
No Master Theorem needed. If you wish, you could prove $S(k)$ equals the summation I mention by induction, but it should be obvious.
Start with T(1) = c, then T(2) = 4c - 1, T(4) = 16c - 5, T(8) = 64c - 21, T(16) = 256c - 85, T(32) = 1024c - 341.
Hopefully you spot that 1 = (4 - 1) / 3, 5 = (16 - 1) / 3, 21 = (64 - 1) / 3, 85 = (256 - 1) / 3, 341 = (1024 - 1) / 3. So we can guess that maybe $T(2^k) = 4^k \cdot c - (4^k - 1) / 3$, and this guess is easily shown to be true by complete induction.
If $n = 2^k$, then $T(n) = n^2 \cdot c - (n^2 - 1) / 3$.