2,523 views
1 votes
1 votes
Consider the following Grammar

S -> Ax/By

A->By/Cw

B->x/Bw

which of the regular expression describe the same set of strings as the grammar?

 

The option are:

(a) xw* y + xw* yx +ywx

(b) xwy + xw* xy +ywx

(c) xw* y + xw X yx +ywx

(d) xw xy + xww* y +ywx

1 Answer

Best answer
5 votes
5 votes
Grammar is

S$\rightarrow$Ax|By

A$\rightarrow$ By|Cw

B$\rightarrow$ x|Bw

C$\rightarrow$ y

Now observe that what strings these productions are generating

C$\rightarrow$ y is generating only y.

B$\rightarrow$ x|Bw is generating x, xw, xww, xwww, ... That is xw*.

A$\rightarrow$ By|Cw is generating xw*y+yw.

S$\rightarrow$ Ax|By is generating (xw*y+yw)x+xw*y .

That is regular expression for given grammar.
selected by

Related questions

2 votes
2 votes
5 answers
3