GATE / CS ARCHIVE

GATE CSE 2013 / QUESTION 9

Reduction-count production terminology

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2013 paper

GATE 2013, Q9 1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 9, GATE 2013: A bottom-up parser processes n tokens using a grammar with no epsilon or “unit” productions, expressly described in the source as A→ε and A→a. What is the maximum number of reductions? A n/2; B n−1; C2n−1; D2^n.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Our answer: B under the displayed no-single-symbol-production interpretation

A reduction with a right-hand side of length at least 2 decreases the stack/sentential length by at least 1. Starting with n terminals and ending with one start symbol thus allows at most n−1 such reductions, attained by binary reductions, giving B. However the source calls A→a a unit-production, whereas standard CFG terminology reserves unit-production for A→B with B a nonterminal. If only standard unit rules and epsilon rules are forbidden, terminal rules A→a remain, and a Chomsky-normal-form derivation can require n terminal reductions plus n−1 binary reductions=2n−1. The key therefore relies on the source’s intended ban on length-one reductions, not the usual terminology alone.

Each reduction replaces a right-hand side by one nonterminal. If every permitted right-hand side has at least two symbols, each reduction shrinks the total length by at least one. Reducing n tokens to one start symbol then permits at most n−1 reductions; a binary parse tree attains that many internal combinations. The caveat is not optional: a normal terminal production A→a has length 1 and would add reductions without shortening the string. The printed parenthetical explicitly rules those out, even though it uses nonstandard “unit” terminology.

Original paper, page 3 · Answer key