Parsing: GATE CS Previous Year Questions

Parsing · Compiler Design

58 questions · asked in 25 of 27 years (2000–2026)

MCQ 46 · MSQ 5 · NAT 71-mark 39 · 2-mark 19

2000Questions per year2026

Questions 36–40 of 58

Q36GATE 20071 markMCQ−0.33 if wrong
Consider the grammar given below:
S→x B∣y AS \rightarrow x \ B \mid y \ A
A→x∣x S∣y A AA \rightarrow x \mid x \ S \mid y \ A \ A
B→y∣y S∣x B BB \rightarrow y \mid y \ S \mid x \ B \ B

Consider the following strings.
i. xxyyx
ii. xxyyxy
iii. xyxy
iv. yxxy
v. yxx
vi. xyx
Which of the above strings are generated by the grammar ?

Q37GATE 20071 markMCQ−0.33 if wrong
Consider an ambiguous grammar G and its disambiguated version D. Let the language recognized by the two grammars be denoted by L(G) and L(D) respectively. Which one of the following is true?

Q38GATE 20071 markMCQ−0.33 if wrong
Consider the CFG with {S, A,B} as the non-terminal alphabet, {a,b} as the terminal alphabet, S as the start symbol and the following set of production rules:
S→\rightarrow aB S→\rightarrowbA
B→\rightarrow b A →\rightarrowa
B→\rightarrow bS A →\rightarrowaS
B→\rightarrow aBB A →\rightarrowbAA

For the string "aabbab", how many derivation trees are there?

Q39GATE 20071 markMCQ−0.33 if wrong
Consider the CFG with {S, A,B} as the non-terminal alphabet, {a,b} as the terminal alphabet, S as the start symbol and the following set of production rules:
S→\rightarrow aB S→\rightarrowbA
B→\rightarrow b A →\rightarrowa
B→\rightarrow bS A →\rightarrowaS
B→\rightarrow aBB A →\rightarrowbAA

Which of the following strings is generated by the grammar?

Q40GATE 20071 markMCQ−0.33 if wrong
Consider the grammar with non-terminals N={S,C,S1S,C,S_1}, terminals T={a,b,i,t,e}, with S as the start symbol, and the following set of rules:

S→iCtSS1∣aS\rightarrow iCtSS_{1}|a
S1→eS∣ϵS_{1}\rightarrow eS|\epsilon
C→bC \rightarrow b

The grammar is NOT LL(1) because:

Keep practising

Topics in Compiler Design

All CS topics ›