How many n strings are there of letters of english alphabet in which there are no consecutive z’s

combinatoricscombinatorics-on-wordsgenerating-functions

I have this combinatorics problem:

How many n strings are there of letters of english alphabet in which there are no consecutive z's?

I want to solve this problem using generating functions

Generating functions of single letters other than z is obvious but i can't find the generating function for z. I know that its function will be a polynomial with degree of $\frac{n}{2}$ or $\frac{n+1}{2}$ depending on whether n is even or odd but i can't find the coefficients of the function. Can anyone lead me to a solution?

Thanks in advance.

Best Answer

The letter $z$ is always followed by a non-$z$, except for the $z$ at the end. So group each $z$ with letter after it to form a double letter. The string is built out of letters and double letters; call each of these a "unit". The generating function of a single unit is $25x+25x^2$; there are $25$ letters of length $1$, and $25$ double letters of length $2$. Since we want a sequence of these units, the g.f. is $$ {1\over 1-25x-25x^2} $$ But wait, we forgot about the possible $z$ at the end! There either is or is not a $z$ at the end, which is accounted for by a factor of $1+x$. Therefore, the answer is actually $$ \bbox[5px,border:1.5px solid black]{{1\over 1-25x-25x^2}\cdot (1+x).} $$