Assume that the SLR Parser for a grammar G has n1 states and the LALR Parser…
2025
Assume that the SLR Parser for a grammar G has n1 states and the LALR Parser for G has n2 states.
- A.
n1 is necessarily less than n2
- B.
n1 is necessarily equal to n2
- C.
n1 is necessarily greater than n2
- D.
None of the above
Attempted by 29 students.
Show answer & explanation
Correct answer: B
Number of states in SLR (n1) = Number of LR(0) states.
Number of states in LALR (n2) = Number of LR(0) states (after merging LR(1) states with identical cores).
Therefore, n1 = n2.
Correct Option: 2