Consider the following grammar S-> PQ P-> aP | b Q-> bQ | a Consider the…
Consider the following grammar
S-> PQ
P-> aP | b
Q-> bQ | a
Consider the following statements.
S1: The grammar has different LMD and RMD for string abba.
S2: The grammar is ambiguous.
Select the correct option.
Answer: C. S1 is true but S2 is false — The grammar has different LMD and RMD for string "abba". LMD: S -> PQ -> aPQ -> abQ -> abbQ -> abba RMD: S -> PQ -> PbQ -> Pba -> aPba -> abba The grammar is…
- A.
Both S1 and S2 are true
- B.
Both S1 and S2 are false
- C.
S1 is true but S2 is false
- D.
S1 is false but S2 is true
Attempted by 56 students.
Show answer & explanation
Correct answer: C
The grammar has different LMD and RMD for string "abba".
LMD: S -> PQ -> aPQ -> abQ -> abbQ -> abba
RMD: S -> PQ -> PbQ -> Pba -> aPba -> abba
The grammar is LL(1) so it cannot be ambiguous.
Loading lesson…