0
$\begingroup$

I am attempting to solve this:

Problem 4.35. Solve the following recurrence exactly.

$$T(n)=\begin{cases} a & \text{if } n=0 \text{ or } n=1 \\ T(n-1)+T(n-2)+cn & \text{otherwise} \end{cases}$$

Express your answer as simply as possible using the $\Theta$ notation and the golden ratio $\phi=\frac{1+\sqrt{5}}{2}$. Note that this is Recurrence 4.1 from Section 4.2.3 if $h(n)=cn$, which represents the time taken by a call on $\operatorname*{Fibrec}(n)$ if we do not count the additions at unit cost. Compare your answer to that of Problem 4.34, in which additions were counted at unit cost.

Here is my work:

enter image description here

  • 1
    I have edited your question in order to include the picture you provided. However please consider typesetting your question using [MathJax](http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference).2017-02-20

1 Answers 1

0

\begin{align*} T(n) &=U_{n+1}+\beta n+\gamma \\ &=T(n-1)+T(n-2)+cn \\ U_{n}+\beta n+\gamma &= [U_{n-1}+\beta(n-1)+\gamma]+[U_{n-2}+\beta(n-2)+\gamma]+cn \\ U_{n} &= U_{n-1}+U_{n-2}+(\beta+c)n+\gamma-3\beta \end{align*}

Considering $$ \left \{ \begin{align*} U_{n} &= U_{n-1}+U_{n-2} \\ \beta+c &= 0 \\ \gamma -3\beta &= 0 \end{align*} \right.$$

Now $$T(n) = U_{n}-c(n+3)$$

When $n=0$, $a=U_{0}-3c$

When $n=1$, $a=U_{1}-4c$

\begin{align*} U_{n} &= a\frac{\phi^{n+1}-(-\phi)^{n+1}}{\sqrt{5}}+c[\phi^{n+2}-(-\phi)^{n+2}] \\ &= aF_{n+1}+cL_{n+2} \\ T_{n} &= aF_{n+1}+c(L_{n+2}-n-3) \\ \end{align*}

where $F_{n}$ and $L_{n}$ are the Fibonacci and Lucas numbers.