retagged by
1,183 views
1 votes
1 votes

 Which of the grammars are ambiguous? 

  1. $S\rightarrow 0S1 \mid 01$
  2. $S\rightarrow +SS \mid -SS \mid a$
  3. $S\rightarrow S(S)S \mid \epsilon$
  4. $S\rightarrow aSbS \mid bSaS \mid \epsilon$
  5. $S\rightarrow a \mid S+S \mid SS \mid S^{\ast} \mid (S)$
retagged by

2 Answers

1 votes
1 votes

OPTION A,B,D-We can easily say its not ambiguous on the basis of observation.

OPTION C- Getting 2 different parse trees for the string { () () }. 

OPTION E- Getting 2 different parse trees for {a+a+a}.

So answer should be C and E.

correct me if m wrong (:

 

edited by
0 votes
0 votes
C.

option c can have two parse tree for same string, {  () ()   } thats why it is ambigious,

Related questions

0 votes
0 votes
0 answers
4