Log In
81 votes

Let $L_1=\{w\in\{0,1\}^*\mid w$ $\text{ has at least as many occurrences of }$ $(110)'$ $\text{s as }$ $(011)'$ $\text{s} \}$. Let $L_2=\{w \in\{0,1\}^*\ \mid w$ $ \text{ has at least as many occurrences of }$ $(000)'$ $\text{s as} $ $(111)'$ $\text{s} \}$. Which one of the following is TRUE?

  1. $L_1$ is regular but not $L_2$
  2. $L_2$ is regular but not $L_1$
  3. Both $L_1$ and $L_2$ are regular
  4. Neither $L_1$ nor $L_2$ are regular
in Theory of Computation
edited by
if we take only 110 now how L1 is regualar?
110 is accepted because the grammar is saying that number of 110 should be >= number of 001.

if only 110 is the string then number of oo1 is zero and number of 110 i 1

therefore 1>= 0 ,hence satisfied
w has at least as many occurrences of (110)β€²s as (011)β€²s

can anyone explain what this statement mean i am little bit confused .
Very good question.
Occurrence of (110)'s >= occurrence of (011)'s

This is what it means?

6 Answers

117 votes
Best answer

(A) is True. Though at first look both $L_1$ and $L_2$ looks non-regular, $L_1$ is in fact regular. The reason is the relation between $110$ and $011$. 

We cannot have two $110'$s in a string without a $011$ or vice verse. And this would mean that we only need a finite number of states to check for acceptance of any word in this language. 

That was just an intuitive explanation. Now I say that L contains all binary strings starting with $11$. Yes, if a binary string starts with $11$, it can never have more no. of $011$ than $110$. 

Lets take an example:
$11 \ 011 \ 011$ -There are two $011'$s. But there are also two $110$'s. Similarly for any binary string starting with $11$. 

Using this property, DFA for $L_1$ can be constructed as follows:

edited by
For set definition there is no general rule- it depends on how a given set is defined. I have seen many people by-hearting many such rules- but GATE can make any number of questions where no such rule follows. Only way is to read and understand the given set definition and solve it. Of course having solved many problems will help - but never by heart any "conditions" as given by many in the above comments.
thankyou sir:-)

@arjun sir thanks.

@akriti Moreover I would like to add point here

{ anbn | a,b belongs to (a+b)*, n>0}  we never write set condition like this here "a,b belongs to (a+b)* "  does not make any meaningful sense bcz on left side of bar of set representation also u have used a,b.

anyhow it is trivial to say "a,b belongs to (a+b)* " .

->>You may write like this { xn yn | x,y belongs to (a+b)*, n>0}

Now for this also L=E* .

Note :-  Link is best to Understand this kind of question.

if it is { anbn | n>0 } then only it is cfl Here actually u are comparing #a = #b 

@Arjun sir plz kindly verify.

yea..dts not correct.thanks

and i too had same question in mind that u asked.

what if the string is odd,how wil u divide it?as now one more constraint is there,that is both 'x' and 'y' should have same length.

for example-aabba

how will you divide?

r u talking wrt to { xn yn | x,y belongs to (a+b)*, n>0} ??

yess..wrt to that only

wrt to { xn yn | x,y belongs to (a+b)*, n>0}

for aabba

Two way are there

x1y1 = (eps)1(aabba)1 =aabba    //set constraint x,y belongs to (a+b)*

x1y1 = (aabba)1(eps)1 =aabba

yes..then it looks regular

and if in this language,#a in x=# b in y condition was there..then still would it have been regular.i dun think so..what do you say??

Yes U r right.

If we add another constraint to  { xn yn | x,y belongs to (a+b)*, n>0} means

 { xn yn | x,y belongs to (a+b)*, n>0 and (no of a in x= no. of b in y) }

then this is non regular as here we have to handle 2 conditions simultaneously 

1) n>0  2)no of a in x= no. of b in y  //which makes it non-regular

Yes in that case here two conditions have to be simultaneously  handled  here equality and no of a in x equals to no of b in y therefore  non regular in that case
What about L2... Why is ut not regular
because to conclude equal number of 000 and 111 we will need a stack and so it is DCFL it will form a language of kind (000^n 111^n) or (111^n 000^n)
sir, i am not stilll able to understand why division is not possible,can you explain again?
But in L1 if we remove atleast than it will not be regular
Am i right
How the concerned strings for L1 and L2 would be written.. Please correct me.

For L1 it would be 110011110011 or 11011011011 ?

For L2 it would be 000111000111 or 000000111111?
how can i say in general??i.e A,B binary string and we have to check equal no of A and B

then Can we conclude lang will be regular if and only if A,B related as AA it must contain one B and BB must contain one A?
can it be generalized that any overlapping pattern will be regular?

Can someone help me with DFA Constructed for L$_{1}$?

17 votes

L1 is regular let us consider the string 011011011011 In this string, number of occurrences of 011 are 4 but when we see here 110 is also occurred and the number of occurrence of 110 is 3. Note that if i add a 0 at the last of string we can have same number of occurrences of 011 and 110 so this string is accepted. We can say if the string is ending with 011 so by appending a 0 we can make 110 also. Now string2: 110110110110 in this number of occurrences of 110 is 4 and 011 is 3 which already satisfy the condition So we can observe here that whenever 110 will be there string will be accepted So with this idea we can build an automata for this. Therefore, it is regular.

can this method work with say : 110110011011?
5 votes
Option A )

it is clear that L2 is not a regular language .

Now L1 , this language can be rewrite like this way the number of 1`s can stay together atmost 11 (two 1`s) if more than 2 1`s occur then it have to be split with 0 and if before the sequence 11 if there is any 0 then it should ends with 0 .

eg : 0110110110110110 (have to end with 0)

What in case string is 11000110.

Here no of 110's is 2 and no of 011's is 1.How its going to accept the string and on what bsis it will count to accept the string.
Please explain.
what about 011110
4 votes

In L1 any string β€œw” must satisfy the condition:
{Number of occurrences of (110)} β‰₯ {Number of occurrences of (011)}
Lets analyse the language, consider a string in which occurrence of (110) is more than one.
The following possibilities are: {1100110, 1101110, 110110, ….}
Please observe whenever strings start with β€œ11” then in every situation whatever comes after β€œ11” the string will never violate the condition. So strings of the form 11(0+1)* will always satisfy the condition.
Consider a string in which occurrence of (011) is more than one.
The following possibilities are: {011011, 0111011, 0110011, ….}
In the following possibilities please observe that number of occurrence β€œ011” is two but number of occurrence of (110) is one, which violate the conditions.
If we add β€œ0” in every string mentioned above, i.e. {0110110, 01110110, 01100110, ….} Now, observe that number of occurrence β€œ011” and the number of occurrence of (110) both are equal, which satisfies the conditions.
With these analysis, we can make the DFA , which is mentioned below.

But language L2 requires infinite comparison to count the occurrences of (000’s) and (111’s), hence it is not regular.

1 vote
Option A is correct

As the relationship between 011 and 110

U cannot have 2 instances of any 1 without the other

Thus making it regular


Where as in case of l2 language the same is not true
Yes due to relationship between 011 and 110  that occurrence of 011 and 110 would be equal
0 votes

yes the answer is A here you can take a look at my answer 

what we sholud notice is that question asks for as any sequences of 110 as 011

in other words

so we need not care and accept anything until the string we are passing through our dfa has an occurrence of 


one key property to notice is that adding a 0 to the end of 011 makes it 0110 and acceptable for us.

so we have to ensure that the string we are passing through our dfa is accepting as long as [(011).1*] is not encountered 

when that is encountered we move to the dead state IN DEAD STATE if the string still has characters and it implies to our terms we send it to one of our accepting states. 

it is essentially a complement of [(011).1*].                                                                                                                           l1 dfa     














no for l2 :

we have a similar condition

but here one thing to observe is that both the substrings are not related to each other hence we can say that  we need to implement a counting logic for 111 and 000 and go to a accepting state whenever the condition described above is met.

it is same as 

dpda where there are same no. of a’s and same no. of b’s.



Related questions

30 votes
3 answers
If $L_1\:=\{a^n \mid n\:\geq\:0\}$ and $L_2\:= \{b^n \mid n\:\geq\:0\}$ , consider $L_1.L_2$ is a regular language $L_1.L_2 = \{a^nb^n \mid n\: \geq \:0\}$ Which one of the following is CORRECT? Only I Only II Both I and II Neither I nor II
asked Sep 28, 2014 in Theory of Computation jothee 4.8k views
71 votes
5 answers
Let $\langle M \rangle$ be the encoding of a Turing machine as a string over $\Sigma=\left\{0,1\right\}$ ... $L$ is: decidable and recursively enumerable undecidable but recursively enumerable undecidable and not recursively enumerable decidable but not recursively enumerable
asked Sep 28, 2014 in Theory of Computation jothee 16.6k views
50 votes
4 answers
Let $A\:\leq_m\:B$ denotes that language $A$ is mapping reducible (also known as many-to-one reducible) to language $B$. Which one of the following is FALSE? If $A\: \leq_m B$ and $B$ is recursive then $A$ is recursive. If $A\: \leq_m B$ and ... recursively enumerable then $A$ is recursively enumerable. If $A\: \leq_m B$ and $B$ is not recursively enumerable then $A$ is not recursively enumerable.
asked Sep 28, 2014 in Theory of Computation jothee 7.8k views
7 votes
2 answers
Let $L=\left \{ w\in\{0,1\}^* | \text{number of occurances of }(110)=\text{number of occurances of}(011) \right \}$ What is $L$? I think $L$ is regular . Regular expression is -: $L=\left \{ 0^{*}+1^{*}+\left ( \left ( \varepsilon +0+1 \right ) \left ( \varepsilon +0+1 \right ) \right ) + 0^{*}\left ( 0110 \right )^*0^{*}+1^* \left ( 11011 \right )^{*}1^{*} \right \}$
asked Oct 9, 2017 in Theory of Computation sourav. 915 views