Chapter 2: Q28P (page 157)
Give unambiguous CFGs for the following languages.
a. { | in every prefix of w the number of a’s is at least the number of b’s}
b. { | the number of a’s and the number of b’s in w are equal}
c. { | the number of a’s is at least the number of b’s in w}?
Short Answer
a. The grammar of that string is
{ | in every prefix of the number of ’s is at least the number of ’s}
b).The grammar of that string is, .
{| the number of’s and the number of’s inare equal}
c).The grammar of that string is, .
{ | the number of ’s is at least the number of ’s in }