11,184 views
26 votes
26 votes

Assume that the SLR parser for a grammar G has $n_1$ states and the LALR parser for G has $n_2$ states. The relationship between $n_1$ and $n_2$ is

  1. $n_1$ is necessarily less than $n_2$
  2. $n_1$ is necessarily equal to $n_2$
  3. $n_1$ is necessarily greater than $n_2$
  4. None of the above

4 Answers

Best answer
37 votes
37 votes
no of states in SLR and LALR are equal

and no of states in SLR and LALR are less than or equal to LR(1)

Correct Answer: $B$
edited by
23 votes
23 votes
no of states

CLR(1)>=LR(0)=SLR(1)=LALR(1)
5 votes
5 votes
ans b)
0 votes
0 votes
In the LALR parser, we only consider the core part of LR(1) items while merging. And in the SLR parser, we only have the core part.
So in LR(1) parser, the increased number of states may appear due to differences in the lookaheads.
Once you ignore the lookaheads in LR(1), the SLR and LALR parsers look the same.
Answer:

Related questions

67 votes
67 votes
10 answers
1
Kathleen asked Sep 16, 2014
26,975 views
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?Removing left recursion aloneFactoring the grammar aloneRemoving left recursion and factor...
40 votes
40 votes
3 answers
2
Kathleen asked Sep 17, 2014
19,883 views
Consider the grammar shown below. $S \rightarrow C \ C$$C \rightarrow c \ C \mid d$This grammar isLL(1)SLR(1) but not LL(1)LALR(1) but not SLR(1)LR(I) but not LALR(1)