Context Free Grammar: GATE CS Previous Year Questions

Context Free Grammar · Theory of Computation

33 questions · asked in 12 of 27 years (2000–2026)

MCQ 26 · MSQ 5 · NAT 21-mark 15 · 2-mark 18

2000Questions per year2026

Questions 11–15 of 33

Q11GATE 2021 (Session 1)2 marksMCQ−0.67 if wrong
Consider the following context-free grammar where the set of terminals is {a,b,c,d,f}\{a,b,c,d,f\}.

S→d a T∣R fT→a S ∣ b a T ∣ϵR→c a T R ∣ϵ\begin{array}{lll} S & \rightarrow & d \: a \: T \mid R \: f \\ T & \rightarrow & a \: S \: \mid \: b \: a \: T \: \mid \epsilon \\ R & \rightarrow & c \: a \: T \: R \: \mid \epsilon \end{array}

The following is a partially-filled LL(1) parsing table.
a b c d f $ S T R S → d a T T → aS T → b a T T → ε R → c a TR R → ε 1 2 3 4
Which one of the following choices represents the correct combination for the numbered cells in the parsing table ("blank" denotes that the corresponding cell is empty)?
(A) 1 S → R f 2 S → R f 3 T → ε 4 T → ε (B) 1 blank 2 S → R f 3 T → ε 4 T → ε (C) 1 S → R f 2 blank 3 blank 4 T → ε (D) 1 blank 2 S → R f 3 blank 4 blank

Q12GATE 2017 (Session 1)1 markMCQ−0.33 if wrong
Consider the following context-free grammar over the alphabet ∑\sum = {a,b,c} with S as the start symbol.

S→\rightarrowabScT|abcT
T→\rightarrowbT|b

Which one of the following represents the language generated by the above grammar ?

Q13GATE 2017 (Session 1)1 markMCQ−0.33 if wrong
Consider the following grammar.

P→\rightarrowxQRS
Q→\rightarrowyz|z
R→\rightarroww|ε\varepsilon
S→\rightarrowy

What is FOLLOW (Q) ?

Q14GATE 2017 (Session 1)2 marksMCQ−0.67 if wrong
If G is grammar with productions
S→SaS∣aSb∣bSa∣SS∣ϵS\rightarrow SaS|aSb|bSa|SS|\epsilon
where S is the start variable, then which one of the following is not generated by G?

Q15GATE 2017 (Session 2)1 markMCQ−0.33 if wrong
Which of the following statements about parser is/are CORRECT?
I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR
III. SLR is more powerful than Canonical LR.

Keep practising

Topics in Theory of Computation

All CS topics ›