[Math] Generating Functions of Binary Strings

discrete mathematicsgenerating-functions

I'm trying to learn generating functions and integer partitions and having particularly difficult time with this question:

"This question is about binary strings where each block of 0s is followed by a block of the same number of 1s."
1. Consider strings of this form which begin with 0 and have only one block of 0s. a) Write out all such strings of size at most 6. b) What is the generating function for these strings?

a) 01, 0011, 000111

b) Issue is that I have no idea how to represent this sequence as a generating function. Can anyone show me how to convert such sequences into generating functions?

Thank you.

Best Answer

Let $f(n)$ be the number of such strings of size $n$. Then the (ordinary) generating function associated with this sequence is $$F(x):=\sum\limits_{n \geq 0} f(n) x^n. $$ Based on your description, $f(n) = 1$ if $n$ is even and $f(n) = 0$ if $n$ is odd. The generating function is $$F(x) = \sum\limits_{n \geq 0}f(n) x^n = 1 + x^2 + x^4 + \cdots = \frac{1}{1 - x^2}.$$


Additionally, if we want the generating function for the number of such strings of size at most $n$, then we have $$\sum\limits_{n \geq 0 } \left(\sum\limits_{k = 0}^n f(k)\right) x^n = \frac{F(x)}{1 - x} = \frac{1}{(1 - x^2)(1 - x)}.$$

Related Question