The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+54 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?

- $L_1$ is regular but not $L_2$
- $L_2$ is regular but not $L_1$
- Both $L_1$ and $L_2$ are regular
- Neither $L_1$ nor $L_2$ are regular

0

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

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

therefore 1>= 0 ,hence satisfied

+83 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:

0

But from the given DFA 11 is accepted only at q5.

So how is 11 011 011 accepted.

Is there any mistake in the DFA? Sorry but i dont understand how after 11 011 and 011 is read.

So how is 11 011 011 accepted.

Is there any mistake in the DFA? Sorry but i dont understand how after 11 011 and 011 is read.

0

Once it reads 11 as the first two letters of a string, state reached is q5. Now whatever is in the input string is just read without a state change. This is represented by the self loop for 0,1 in q5.

0

I understand the concept. and you explained it beautifully.

but in DFA something wrong is at state q5.

that accept the string "110" [ one occurence of 110 and no occurence of 011] .

some correction is required at state q5 for the transition on symbol 0

but in DFA something wrong is at state q5.

that accept the string "110" [ one occurence of 110 and no occurence of 011] .

some correction is required at state q5 for the transition on symbol 0

+6

Answer is C. Any string over a and b can be split in to two parts such that number of a's on left part is equal to number of b's on right part.

a - x = ⋴, y = a

b - x = b, y = ⋴

aa - x = ⋴, y = aa

ab - x = a, y = b

ba - x = b, y = a

bb - x = bb, y = ⋴

.....

ababbba - x = abab, y = bba

,,,

a - x = ⋴, y = a

b - x = b, y = ⋴

aa - x = ⋴, y = aa

ab - x = a, y = b

ba - x = b, y = a

bb - x = bb, y = ⋴

.....

ababbba - x = abab, y = bba

,,,

0

can we say regular expression for L1 is (110)(0+1)*(011) + (011)(0+1)*(110) + Epsilon. Is it correct ?

0

Why it is sigma kleen star when we have to make comparison between no of a and no of b it should be done by pda na and it should be cfl bt nt regular

0

and moreover,i dun fing C option even logical,

lets take aab ,this word is part of sigma kleen but here no. of a != no. of b,so how can you say that correct option is C

answr should be B because this language is CFL but not regular

lets take aab ,this word is part of sigma kleen but here no. of a != no. of b,so how can you say that correct option is C

answr should be B because this language is CFL but not regular

0

below ques ans should be op(b) i.e cfl but not regular bez it is a problem of counting compairsion without order

+1

Arjun sir is abs. correct here option C is only ans.

@dileswar @Akriti @Kaluti

Plz read it carefully

Any string over a and b can be split in to two parts such that number of a's on left part is equal to number of b's on right part.

Example:-aab

Left Part x =a //#a=1

Right Part y=ab //#b=1

Note:- If u still not agree then comment ur strings from E* .i will divide them.

0

@rajesh ,then the langauge { a^{n}b^{n} | a,b belongs to (a+b)^{*, }n>0} should also be regular as here also,we can divide them into groups and say number of A = number of B.

can you tell the difference??

+2

@Akriti A string is divided because $L$ is defined as $xy$ where $x$ and $y$ can by any possible string. For your language there is only one string and hence no division possible. To become an element of a set one needs to just satisfy the set definition - any how just satisfy it.

0

ok.i understood arjun sir.

so sir,if any other condition instead of equality of a and b would have been given,then also we can divide like this..??

so sir,if any other condition instead of equality of a and b would have been given,then also we can divide like this..??

+3

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.

0

@arjun sir thanks.

@akriti Moreover I would like to add point here

{ a^{n}b^{n} | 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 { x^{n} y^{n} | x,y belongs to (a+b)^{*, }n>0}

Now for this also L=E* .

Note :-http://gatecse.in/category/theory-of-computation/page/2/ Link is best to Understand this kind of question.

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

@Arjun sir plz kindly verify.

0

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?

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?

0

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

for aabba

Two way are there

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

x^{1}y^{1} = (aabba)^{1}(eps)^{1} =aabba

0

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??

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??

0

Yes U r right.

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

{ x^{n} y^{n} | 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

0

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

0

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)

+12 votes

+4 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)

110110110110110

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)

110110110110110

- All categories
- General Aptitude 1.6k
- Engineering Mathematics 7.5k
- Digital Logic 3k
- Programming & DS 4.9k
- Algorithms 4.3k
- Theory of Computation 5.9k
- Compiler Design 2.1k
- Databases 4.2k
- CO & Architecture 3.5k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.5k
- Admissions 588
- Exam Queries 568
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,071 questions

53,206 answers

184,562 comments

70,424 users