Defining a recurrence relation for number of words of length $n$ formed from the alphabet $\{x, y, z\}$ that do not contain the string $xxx$

305 Views Asked by At

$a_{n}$ describes the number of words that can be composed of this particular set $\{x,y,z\}$. The sequence $xxx$ must not appear in the word.

Example: $a_{1}=3$, $a_{2}=9$, $a_{3}=26$

The answer is: $a_{n}=2a_{n-1}+2a_{n-2}+2a_{n-3}$

How did they reach this solution? Any sort of guidance will be appreciated.

1

There are 1 best solutions below

0
On

You have correctly found the initial conditions.

Notice that any admissible word must begin with $y$, $z$, $xy$, $xz$, $xxy$, or $xxz$.

An admissible word of length $n$ that begins with $y$ or $z$ can be formed by appending an admissible word of length $n - 1$, of which there are $a_{n - 1}$, to a word that begins with $y$ or $z$. Thus, there are $2a_{n - 1}$ words that begin with $y$ or $z$.

An admissible word of length $n$ that begins with $xy$ or $xz$ can be formed by appending an admissible word of length $n - 2$, of which there are $a_{n - 2}$, to a word that begins with $y$ or $z$. Thus, there are $2a_{n - 2}$ words that begin with $y$ or $z$.

I will let you write the argument for words that begin with $xxy$ or $xxz$.