0

We were asked the following question in our exam:

Solve or bound the recurrence T(n) = 2T(n − 3) for n>3 provided T(1) = T(2) = T(3) = 1.

How do I go about solving this type of recurrence? For a normal recurrence of the form T(n) = 2T(n - 3) + cn, I would have considered cn to be the root and then solved the remainder of the tree. However, since the constant term is missing here, it means that the work done in each recursive call is 0. So, what would be the time complexity? Is my understanding incorrect?

Thanks for you help!

P.S.: This is not this, because this one has the constant term missing.

user6490375
  • 101
  • 1

1 Answers1

3

It is easy to see the first nine terms of $\small T(n)$ is:

$$ \small \begin{array}{|c|c|c|c|c|c|c|c|c|} \hline \color{red}{T(1)} & \color{blue}{T(2)} & \color{olive}{T(3)} & \color{red}{T(4)} & \color{blue}{T(5)} & \color{olive}{T(6)} & \color{red}{T(7)} & \color{blue}{T(8)} & \color{olive}{T(9)} \\ \hline 1 & 1 & 1 & 2 & 2 & 2 & 4 & 4 & 4 \\ \hline \end{array} $$

Observation: For integer $\small k \geq 0$, $\small T(3k+1) = T(3k+2) = T(3k+3)$. You can prove it by induction, where the base case is $\small T(1) = T(2) = T(3)= 1$.

Given $\small n$, let $\small k$ be the smallest integer with $\small 3k \geq n$. In other words, $\small k = \lceil n / 3\rceil$. By the observation above, $\small T(n) = T(3k)$. Therefore, we have $$ \small T(n) = T(3k) = 2\cdot T(3(k-1)) = 2^2\cdot T(3(k-2)) = \cdots = 2^{k-1}T(3) = 2^{k-1} = 2^{\lceil n / 3\rceil - 1} $$

PSPACEhard
  • 826
  • 7
  • 6