Recurrence relation. Application to ternary sequences

100 Views Asked by At

The question is:

How many ternary sequences have no double zero?

For this I understand that our $n$-digit sequence either have $0,1,\dots,n$ zeroes, is this ok?

If the answer of above is positive, then on the $n$th position we can have either a 1 or a 2, thus $2a_{n-1}$ sequences, no problem here.

However, if the string in the $n$th position there's a zero, then:

$$ \dots 10 \\ \dots 20 $$

and the result claims to be: $a_n = 2(a_{n-1} + a_{n-2})$. However, my problem is the following: do I have to exclude the cases in the last part where there's a zero somewhere in the previous $n-2$ positions?

1

There are 1 best solutions below

9
On

Let $A_n$ denote the total number of "good" strings of length $n$.

Let $B_n$ denote the total number of "good" strings of length $n$ which do not end in $0$

Let $C_n$ denote the total number of "good" strings of length $n$ which end in $0$.

We have: $$A_n=B_n+C_n$$

$$B_n=2B_{n-1}+2C_{n-1}=2A_{n-1}$$

$$C_n=B_{n-1}=2A_{n-2}$$

Combining all this we get $$A_n=2\left(A_{n-1}+A_{n-2}\right)$$