Decomposition of binary strings that have an even number of blocks

1k Views Asked by At

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^*$. My question is How I can modify this decomposition to get what I need? Thanks

1

There are 1 best solutions below

2
On

If we collapse blocks to a single character we are asking for strings having even length and runs of length $1$ only. These are \begin{align*} (01)^*\cup(10)^*=\{\varepsilon,01,10,0101,1010,010101,101010,\ldots\}\tag{1} \end{align*}

Expanding each character in (1) by one or more occurrences of it $$0\longrightarrow 0^+\qquad\text{and}\qquad 1\longrightarrow 1^+$$ generates strings with an even number of blocks:

\begin{align*} (0^+1^+)^*\cup(1^+0^+)^* \end{align*}