11,534 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
39 votes
39 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

28.2k
views
10 answers
67 votes
Kathleen asked Sep 16, 2014
28,238 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...
20.6k
views
3 answers
40 votes
Kathleen asked Sep 17, 2014
20,620 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)
13.7k
views
3 answers
34 votes
Kathleen asked Sep 17, 2014
13,705 views
Consider the grammar shown below$S \rightarrow i E t S S’ \mid a$$S’ \rightarrow e S \mid \epsilon$$E \rightarrow b$In the predictive parse table, $M,$ of this gramma...
16.7k
views
4 answers
51 votes
Kathleen asked Sep 17, 2014
16,723 views
Which of the following is NOT an advantage of using shared, dynamically linked libraries as opposed to using statistically linked libraries?Smaller sizes of executable fi...