Given the following definition, compute Q(5).
Q(n) = 

0
if n = 0
2
if n = 1
4
if n = 2
Q(n − 1) + Q(n − 2) + Q(n − 3)  
if n > 2

Respuesta :

[tex]Q(n)=\begin{cases}0&\text{for }n=0\\2&\text{for }n=1\\4&\text{for }n=2\\Q(n-1)+Q(n-2)+Q(n-3)&\text{for }n>2\end{cases}[/tex]

[tex]\implies Q(3)=Q(2)+Q(1)+Q(0)=4+2+0=6[/tex]
[tex]\implies Q(4)=Q(3)+Q(2)+Q(1)=6+4+2=12[/tex]
[tex]\implies Q(5)=Q(4)+Q(3)+Q(2)=12+6+4=22[/tex]