The Gateway to Computer Science Excellence
+19 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
in Compiler Design by Veteran (52.2k points) | 2.8k views
please explain me why n1 is necessarily equal to n2 and why not n1 is necessarily less than n2.

3 Answers

+24 votes
Best answer
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$
by Boss (31.4k points)
edited by

Answer should be D. Right?

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

@Rishabh HEre comparision is asked for SLR(1) and LALR(1) in questions and no. in states in both these are equal.
+14 votes
no of states

by Active (2.9k points)
+5 votes
ans b)
by Loyal (5.2k points)
I think it should be less than equal to?
So pls explain whether it is less than equals to or only equal?
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,741 questions
57,253 answers
104,707 users