GATE Exam  >  GATE Questions  >   Consider the following augmented grammarS→aA... Start Learning for Free
Consider the following augmented grammar
S→aAb |eb
A→e |f
Find the number of states in LR(0) construction.
  • a)
    1
  • b)
    5
  • c)
    7
  • d)
    9
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Consider the following augmented grammarS→aAb |ebA→e |fFind the numbe...
No conflict in above DFA.
View all questions of this test
Most Upvoted Answer
Consider the following augmented grammarS→aAb |ebA→e |fFind the numbe...
LR(0) Construction

Given Grammar:
S → aAb | eb
A → e | f

Step 1: Augment the Grammar
We need to augment the grammar by adding a new start symbol and a production for it.
S' → S

The augmented grammar becomes:
S' → S
S → aAb | eb
A → e | f

Step 2: Compute the Closure of the Start State
The closure of the start state is the set of LR(0) items that can be derived from the start state.

The start state is {S' → .S}, where the dot indicates the position of the parser.

The closure of the start state is:
{S' → .S, S → .aAb, S → .eb, A → .e, A → .f}

Step 3: Compute the GOTO Sets
For each LR(0) item, compute the GOTO sets by finding the items that can be derived from the current item by shifting the dot one position to the right.

GOTO(I, X) = Closure({A → αX.β | A → α.Xβ ∈ I})

For example, GOTO({S' → .S}, S) = {S' → S.}

Step 4: Construct the LR(0) States
Start with the closure of the start state as the initial state.

I0 = Closure({S' → .S, S → .aAb, S → .eb, A → .e, A → .f})

Next, for each item A → α.Xβ in Ii and for each grammar symbol X, compute GOTO(Ii, X) and add it as a new state if it is not already in the set of states.

Continue this process until no new states can be added.

Step 5: Determine the Number of States
Count the number of states obtained in the LR(0) construction.

In this case, we have 9 states:

I0 = {S' → .S, S → .aAb, S → .eb, A → .e, A → .f}
I1 = {S' → S.}
I2 = {S → a.Ab, A → .e, A → .f}
I3 = {S → aA.b}
I4 = {A → e.}
I5 = {S → .eb}
I6 = {A → .e}
I7 = {S → aAb.}
I8 = {A → .f}

Therefore, the correct answer is option D) 9.
Explore Courses for GATE exam
Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer?
Question Description
Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer?.
Solutions for Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer?, a detailed solution for Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the following augmented grammarS→aAb |ebA→e |fFind the number of states in LR(0) construction.a)1b)5c)7d)9Correct answer is option 'D'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev