Consider the following grammar. S → aSB d B → b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2020 · Q24
Time
Your answerNumerical answer
Solution
Official answer: 7
Lexical Analysis, Parsing and SDTA bottom-up parser traces the rightmost derivation in reverse to reduce the input string to the start symbol .
Let us construct the rightmost derivation of the string from :
(using )
(using )
(using )
(using )
(using )
(using )
The bottom-up parser performs these 7 derivation steps in reverse order as reductions:
Step 1: , reducing to
Step 2: , reducing to
Step 3: , reducing to
Step 4: , reducing to
Step 5: , reducing to
Step 6: , reducing to
Step 7: , reducing to
Total number of reduction steps is 7.
Try the question first, then check your work.
Examiner trap
Find the rightmost derivation of the string from the start symbol . The number of reduction steps in a bottom-up parse equals the number of steps in the rightmost derivation.
This Lexical Analysis, Parsing and SDT previous year question is Q24 of the GATE CSE 2020 paper. Find more GATE CSE PYQs on Lexical Analysis, Parsing and SDT in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Lexical Analysis, Parsing and SDT PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Lexical Analysis, Parsing and SDT has 14 GATE CSE PYQs across 12 papers from 2011 to 2025. 2 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2020.
How GATE tests Lexical Analysis, Parsing and SDTIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.