Regular Expressions that define given languages

633 Views Asked by At

A few of these here I just wanted to make sure I had right.

For $\Sigma = \{0,1\}$

a. The language consisting of all strings of 0's and 1's that have even length and where 0's and 1's alternate

I got $(10)^* \cup (01)^*$

b. The language consisting of all strings of 0's and 1's with an even number of 1's. Such strings are said to have even parity.

I had $(011)^* \cup (110)^*$

c. And the language consisting of all strings of 0's and 1's that do not contain two consecutive 1's.

I had $(01)^*$

Please say if I'm wrong and why, would help a lot.

1

There are 1 best solutions below

3
On BEST ANSWER

a is right.

b is wrong because it doesn't include $0011$. A correct formula is $(0^*10^*1)^*0^*$.

c is wrong because it doesn't include $1010$ or $0010$. A correct formula is $(10 \cup 0)^*$.