in Theory of Computation edited by
1,226 views
1 vote
1 vote

Assume $\sum = \left \{ a,b \right \}$ 

  1. $L = \left \{ w : n_{a}\left ( w \right ) = n_{b}\left ( w \right ) + 1 \right \}$
  2. $L = \left \{ w : n_{a}\left ( w \right ) > n_{b}\left ( w \right ) \right \}$
  3. $L = \left \{ w : n_{a}\left ( w \right ) = 2n_{b}\left ( w \right ) \right \}$
  4. $L = \left \{ w \in \left \{ a,b \right \}^{*} : \left |n_{a}\left ( w \right ) - n_{b}\left ( w \right ) \right | = 1 \right \}$
in Theory of Computation edited by
1.2k views

2 Comments

All are $DCFL.$
0
0
ok but grammars? atleast for (1)
0
0

3 Answers

4 votes
4 votes
Best answer

1) S -> aX / XS

  X -> XX / aXb / bXa / $\epsilon$ ( Thanks  @Tarun kushwaha 1 )



2) S-> aSb | bSa | SS |A

     A-> aA | a

3) S-> aaSb | bSaa |aSba|abSa|SS|ε (thanks @srestha)

4)S -> aX | bX | XS

  X -> aXb | bXa | XX |ε

edited by

4 Comments

not able to generate aba from 3rd one
0
0

it will be

S-> aaSb | bSaa |aSba|abSa|SS|ε

1
1
@tesla

typing mistake in the line

3) S-> aaSb | bSaa |SS|aSba|abSaε
0
0
2 votes
2 votes

Grammar for 1st..

S --> aX / XS

X --> XX / aXb / bXa / λ

0 votes
0 votes
are the following grammars correct ?

1.     S-> aA / Aa

        A -> aAbA / bAaA / ϵ

2.    S -> aSbS / bSaS / aS / a

3.    S -> aaSbS / bSaaS /  ϵ

4.    S -> aSbS / bSaS / a /b

3 Comments

not able to generate aba from 3rd one
0
0
yes i missed that. Thankyou.
0
0
and not able to generate abbaaa from 2nd one
0
0

Related questions