Skip to content
GATEiit

GATE CSE 2019 Q29: FOLLOW set of B in S → Aa, A → BD, B → b | ε, D → d | ε

Syllabus topic: Lexical analysis, parsing and syntax-directed translation

Question

Consider the grammar given below:

S→Aa

A→BD

B→b∣ϵ

D→d∣ϵ

Let a, b, d, and $ be indexed as follows:

abd$
3210

Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a,b,d,$}, then the answer should be 3210)

Answer: ________.

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 31 (official GATE 2019 final answer key)

Concept used: FOLLOW(B) contains FIRST of what follows B; if that can derive ϵ, it also includes FOLLOW of the left-hand side.

Concept notes

Loading notes…

First step: From A→BD, add FIRST(D) minus ϵ to FOLLOW(B); since D is nullable, also add FOLLOW(A), which comes from S→Aa.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Lexical analysis, parsing and syntax-directed translation

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key