• edited by
807 views

2 Answers

Best answer
1 1 vote

1. we  find  more than 1 parse tree for  string ab , so it is ambigious.
2. no left recursive . we dont have any A--A op B  kind of production so 2nd is wrong.
3. no , it is not un-ambigious
4.wrong
soln -A

• selected by
3 3 votes

The given grammar is ambiguous.Let us see how.

First of all it is not left recursive since for left recursion we must have production of type

S --> Sa directly or indirectly which is not the case here.

Consider drawing the derivation of a string say ab , so ambiguity comes as which of the 2  "A's" to be substituted first.Either of them can be done.To elaborate , we see reduction of "ab" in 2 ways , sufficient to show grammar is ambiguous.

S --> Aab --> ab [In case second A is substituted by epsilon]

S --> aAb --> ab [In case first A is substituted by epsilon]

So corresponding to these 2 reductions , we will get different derivation trees.Hence the grammar is ambiguous.

For more reference and clarity , u can check the following link where 

S -> aS | aSbS | epsilon is proved ambiguous on the similar ground :

https://cs.nyu.edu/courses/spring01/G22.2110-001/ans1.html


Hence A) should be the correct option.

• edited by
Position:
Show:

Related questions

0 0 votes
0 0 answers
35
35 views
RAM _00 asked 2 days ago
35 views
Which of the following statements about lexical error handling is/are TRUE?A. Lexical analyzers may use finite automata with error transitions to recognize malformed toke...
2 2 votes
2 answers 2 answers
604
604 views
UNKNOWN_ANONYMUS asked Aug 26, 2025
604 views
WHICH OF THE FOLLOWING is/are TRUE FOR SYMBOL TABLE ??
0 0 votes
0 0 answers
450
450 views
1 1 vote
0 0 answers
371
371 views
harsh_20 asked Jan 16, 2025
371 views
The following program uses six temporary variables p, q, r, s, tand u. The code is:p=6q=7t=p*qs=t +pu=8u=s* ps =p +ur=r*qt =t +preturn tAssuming that all operations take ...