GateAI
Parsing

GATE CSE 2013 · Q9

MCQ1 markMedium

Time

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→ϵ\text{A} \rightarrow \epsilon and A→a\text{A} \rightarrow \text{a}) to parse a string with nn tokens?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) n-1

Parsing

In 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 nn terminal tokens.

  • Since the grammar contains no epsilon-productions (A→ϵA \rightarrow \epsilon) and no single-symbol productions (A→aA \rightarrow a), every production rule must have at least two symbols on its right-hand side (i.e., length ≥2\ge 2).

  • A reduction using a rule of length k≥2k \ge 2 reduces the total count of symbols on the stack by k−1≥1k - 1 \ge 1.

  • To reduce nn tokens to a single start symbol, the net reduction in symbol count must be n−1n - 1.

  • The maximum number of reductions is achieved when every reduction consumes the minimum possible number of symbols, which is 22 symbols (reducing 22 symbols to 11, yielding a reduction of 11 symbol per move):

    Maximum reduce moves=n−1\text{Maximum reduce moves} = n - 1

Thus, option (B) is correct.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Parsing in GATE CSE

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 Parsing

More from GATE CSE 2013

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2013 · Q9 · MCQ

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.