What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type A → and A → a) to parse a string with n tokens?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2013 · Q9
Time
Select one answerSingle correct
Solution
Official answer: B) n-1
ParsingIn a bottom-up parser, each reduce move replaces a handle (the right-hand side of a production rule) with a non-terminal.
The input initially consists of terminal tokens.
Since the grammar contains no epsilon-productions () and no single-symbol productions (), every production rule must have at least two symbols on its right-hand side (i.e., length ).
A reduction using a rule of length reduces the total count of symbols on the stack by .
To reduce tokens to a single start symbol, the net reduction in symbol count must be .
The maximum number of reductions is achieved when every reduction consumes the minimum possible number of symbols, which is symbols (reducing symbols to , yielding a reduction of symbol per move):
Thus, option (B) is correct.
Try the question first, then check your work.
Examiner trap
Each reduction step must reduce at least two symbols into one non-terminal symbol, decreasing the length of the sentential form by at least 1.
This Parsing previous year question is Q9 of the GATE CSE 2013 paper. Find more GATE CSE PYQs on Parsing 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 Parsing 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.
Parsing has 23 GATE CSE PYQs across 16 papers from 2012 to 2026. 5 of them are 1-mark MCQs like this one, and GATE CSE 2013 has 2.
How GATE tests ParsingIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.