• edited by
3,161 views
12 12 votes
Write a regular expression for all strings of $0$’s and $1$’s in which the total number of $0$’s to the right of each $1$ is even. Justify your answer.

4 Answers

Best answer
14 14 votes

Here Total no. of $0$'s to the right of each $1$'s should be even. So, to the left side of every $1$'s no. of $0$'s can be anything.

$L=\{ \epsilon ,0,00,000,01,011,0111,1,11,111,1111,100,10000,100100,10010000...................\}$

Hence,

$\mathbf{R.E.=0^*(1+00)^*= 0^*(1(00)^*)^* = 0^*(1+(00)^*)^* =0^*(1^*+(00))^* = 0^*(1^*+(00)^*)^*}$

• edited by
0 0 votes

I tried making an FSM and then reducing it to get 0*1(1 + 00)*, which accepts all legal strings.

0 0 votes

Simple logic:

(you may draw the corresponding DFA, if that approach is more suitable for you, as given in the picture by @mohitjarvissharma)


For $\#1's \ge 1$ Regular Exp : $0^*1(1+00)^*$

For $\#1's = 0$ Regular Exp : $0^*$

Combining them : $0^*1(1+00)^* + 0^* = 0^*(1+00)^* $ 

This is the simplest interpretation of the Regular Expression, it can be further represented as (all are given in @LeenSharma 's answer):
$ 0^*(1^*+00)^*$ or $ 0^*(1+(00)^*)^*$ or  $ 0^*(1^*+(00)^*)^*$ or $ 0^*(1(00)^*)^*$

All of the above are valid!

Position:
Show:

Related questions

9 9 votes
2 answers 2 answers
1.4k
1.4k views
go_editor asked Jun 1, 2016
1,395 views
Give a context-free grammar $G$ that generates $L = \{0^i1^j0^k \mid i + k = j\}$.Prove that $L = L(G)$.
1 1 vote
0 0 answers
731
731 views
go_editor asked Jun 1, 2016
731 views
A connected, simple, undirected planar graph $G(V, E)$ is given where $V$ denotes the set of vertices and E denotes the set of edges. In $V$, there is a designated source...
1 1 vote
0 0 answers
777
777 views
go_editor asked Jun 1, 2016
777 views
A school database maintains the following relations for its students, teachers and subjects:Student(st_name, st_address, class, section, roll_no, regn_no)Teacher(t_name, ...
3 3 votes
2 2 answers
1.7k
1.7k views
go_editor asked Jun 1, 2016
1,748 views
A block of bits with $n$ rows and $m$ columns uses horizontal and vertical parity bits for error detection. If exactly 4 bits are in error during transmission, derive an ...