StreakPeaked· Practice

ExamsGATETechnical

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?

  1. n/2
  2. n-1
  3. 2n-1
  4. 2ⁿ

Correct answer: n-1

Solution

In a bottom-up parsing process, each reduce move corresponds to reducing a production rule, and since the parser must eventually reduce the entire input string to the start symbol, the maximum number of reduce moves is one less than the number of tokens, which is n-1.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →