• edited by
39,083 views
92 92 votes

Let $L=\{ w \in \:(0+1)^* \mid w\text{ has even number of }1s \}$. i.e., $L$ is the set of all the bit strings with even numbers of $1$s. Which one of the regular expressions below represents $L$?

  1. $(0^*10^*1)^*$
  2. $0^*(10^*10^*)^*$
  3. $0^*(10^*1)^*0^*$
  4. $0^*1(10^*1)^*10^*$

12 Answers

Best answer
96 96 votes
  1. - If the string contains a $1$, it must end in a $1$ hence cannot generate all bit strings with even number of $1$'s (eg, $1010$)
  2. - is the answer
  3. - between the second and third $1$'s a $0$ is not allowed (eg, $011011$)
  4. - $00$ is not allowed, zero is an even number.
• edited by
34 34 votes
(A) ( 0 * 10 * 1) * --->0110(valid string) not possible to produce from this Regular Expression.

(B) 0 * (10 * 10 *) * ---> Produces all strings with even number of 1's.

(C) 0 * (10 * 1 ) * 0 * ----> 11011(valid string) cannot be produced from this.

(D) 0 * 1 (10 * 1) * 10 ---> epsilon or 0 (valid strings) can not be produced.( even number of 1's includes zero number of 1's)

Therefore Answer : B Correct.
• edited by
19 19 votes

 method 1: draw the DFA and then derive reg ex from it 

   

method 2: by verification 

option a. does n't generates strings ending with 0 ex:1100

option c :does n't generates strings like 110011,1101111,011011,...i.e it does n't producing 0 between 2nd 1 and 3rd 1 in the string

option d: does n't generate $\epsilon$ 

option b: is the answer

• edited by
1 1 vote
We can omit out A because it cannot generate strings ending with 0 like 00

Omit D bcoz it cannot generate epsilon

now for B and C .we can clearly observe that C is a subset of B .Any language generated by C can be generated by B so B is the correct option.
0 0 votes

The best way to find correct answer is option elimination method. We will guess strings which has even number of 1’s and that is not generated by wrong options OR which generate strings which doesn’t have even number of 1’s.
Option A: (reg expr: (0*10*1)* ) doesn’t generate string such as { 110, 1100,....}
Option C: (reg expr: 0*(10*1*)*0* generate string such as {1, 111,....} which have odd number of 1’s.
Option D: (reg expr: 0*1(10*1)*10* doesn’t generate strings such as { 11101, 1111101, ….}.
hence B is the answer

1 flag:
✌ Edit necessary (Vaibhav_singh_1605)
Answer:
Position:
Show:

Related questions

89 89 votes
10 answers 10 answers
39.3k
39.3k views
go_editor asked Sep 30, 2014
39,345 views
Let $w$ be any string of length $n$ in $\{0,1\}^*$. Let $L$ be the set of all substrings of $w$. What is the minimum number of states in non-deterministic finite automati...
53 53 votes
2 answers 2 answers
18.2k
18.2k views
go_editor asked Sep 30, 2014
18,171 views
Consider the languages$L1=\{0^i1^j\ \mid i \neq j\}, $$L2=\{0^i1^j\mid i=j\},$$L3=\{0^i1^j \mid i=2j+1\},$$L4=\{0^i1^j \mid i\neq2j\}$Only $L2$ is context free.Only $L2$ ...
73 73 votes
3 answers 3 answers
26.2k
26.2k views
go_editor asked Sep 29, 2014
26,204 views
Let $L_1$ be the recursive language. Let $L_2$ and $L_3$ be languages that are recursively enumerable but not recursive. Which of the following statements is not necessar...
97 97 votes
10 answers 10 answers
40.7k
40.7k views
go_editor asked Apr 21, 2016
40,672 views
A computer system has an $L1$ cache, an $L2$ cache, and a main memory unit connected as shown below. The block size in $L1$ cache is $4$ words. The block size in $L2$ cac...