0
$\begingroup$

So I need to find the explicit formula for the number of the non empty 0-1 strings that have an even number of blocks. I need to compute the decomposition of binary strings that have an even number of blocks. I know general form of decomposition is 1∗(00∗11∗)∗0∗

And have found that,

If we collapse blocks to a single character we are asking for strings having even length and runs of length 1 1 only. These are (01)∗∪(10)∗={ε,01,10,0101,1010,010101,101010,…} call this (1)

Expanding each character in (1) by one or more occurrences of it 0⟶0+and1⟶1+

generates strings with an even number of blocks:

(0+1+)∗∪(1+0+)∗

so far it makes sense, but now how would I go about finding an explicit formula?

I am currently stuck trying to find the generating function,

if the generating function of (0+ 1+)* = 1 / (1-x)^2 and then similarly the generating function of (1+ 0+)* is also 1 / (1-x)^2

then the complete generating function of (0+1+)* ∪(1+0+)* would be [ 1 / (1- (1-x)^2) ]^2 ?

  • 1
    A block is a run of $0$'s or $1$'s? By an easy induction, I get that the number of strings of length $n$ with an even number of blocks is $2^{n-1}$ for $n \ge 2$, and the same for an odd number of blocks.2017-02-28

1 Answers 1

0

Call the regular expression for even binary strings $R_e$, for odd binary strings $R_o$ and $R$ for total binary strings then

$$R=(\mathbf{0}+\mathbf{1})^{*}=R_e+R_o$$

The generating function equivalent is

$$f(x)=\frac{1}{1-2x}=f_e(x)+f_o(x)$$

and surely every odd string ending in 1 can be obtained from an even string ending in a 0 by appending either 1, 11, 111 etc or it is a string of only 1s

$$R_{o1}=R_{e0}\mathbf{11^{*}}+\mathbf{11^{*}}$$

similarly every odd string ending in 0 can be obtained from an even string ending in a 1 by appending either 0, 00, 000 etc or it is a string of only 0s

$$R_{o0}=R_{e1}\mathbf{00^{*}}+\mathbf{00^{*}}$$

or equivalently with generating functions

$$f_{o1}(x)=\frac{x}{1-x}f_{e0}(x)+\frac{x}{1-x}\\ f_{o0}(x)=\frac{x}{1-x}f_{e1}(x)+\frac{x}{1-x}$$

of course

$$R_{e}=R_{e1}+R_{e0}+\epsilon\\ R_{o}=R_{o1}+R_{o0}$$

where $\epsilon$ is the empty string. These have generating function equivalents

$$f_{e}(x)=f_{e1}(x)+f_{e0}(x)+1\\ f_{o}(x)=f_{o1}(x)+f_{o0}(x)\\ \Rightarrow f_o(x)=\frac{x}{1-x}(f_e(x)-1)+\frac{2x}{1-x}$$

then

$$f(x)=\frac{1}{1-2x}=f_e(x)+f_o(x)\\ \Rightarrow \frac{1}{1-2x}=f_e(x)\left(\frac{x}{1-x}+1\right)+\frac{x}{1-x}\\ \Rightarrow f_e(x)=\frac{1-x}{1-2x}-x\\ \boxed{f_e(x)=\frac{1-2x+2x^2}{1-2x}}$$