Regular Expression that accepts a language L

54 Views Asked by At

Given, $L=\{ x \in\{0,\,1\}^* | x=0^n1^m \text{ and }n+m\text{ is a multiple of }3\}$ give a regexp that accepts the language.

My thoughts are: $(000)^*(\epsilon + 001 + 011)(111)^*$
Is this right?

1

There are 1 best solutions below

4
On BEST ANSWER

HINT: Divide the word into blocks of $3$; the critical point is where the zeroes and ones meet. If $n=3k+1$, say, that block will be $011$. If $n$ is a multiple of $3$, on the other hand, there won’t be a mixed block: you’ll just have $(000)^*(111)^*$. Look at the possibilities for the mixed block, when it exists.