I have been given the following problem:
Find a recurrence relation for the number of ternary strings $(0,1,2)$ of length $n$ such that
(a) they do not contain $22$ as a substring
(b) they do not contain, neither $20$ nor $22$, as a substring
I have done the same steps from Recurrence Relations with ternary strings, and for (a) I get the recurrence relation $a_n=3a_{n-1}-a_{n-2}$, with $a_1=3$ & $a_2=8$.
I wrote down $a_1$ and $a_2$ manually:
$a_1=0,1,2$
$a_2=00,01,02,10,11,12,20,21$
Am I correct in working out that for (b), the recurrence relation is $a_n=3a_{n-1}-2a_{a-2}$, with $a_1=3$ and $a_2=7$?
I mean, there are 2 options being excluded instead of a single option...
Again, I wrote down $a_1$ and $a_2$ manually:
$a_1=0,1,2$
$a_2=00,01,02,10,11,12,21$