Consider following statements regarding total number of moves in bottom – up parsers for different scenario:

  • (i) (2n-1) is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon production and unit-production (i.e., of type A→ϵ and A→a) to parse a string with n tokens.
  • (ii) (2n-1) is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with only double variable production, epsilon production and unit-productions (i.e., of type A→BC, A→ϵ and A→a) to parse a string with n tokens.

(A) Only statement (i) is correct
(B) Only statement (ii) is correct
(C) Both statement (i) and (ii) are correct
(D) Neither statement (i) nor (ii) is correct


Answer: (B)

Explanation: Statement (i) is not correct. It should be (n-1), take example string = aabb and grammar S→AB; A→aa|AB; B→bb|BA.
Statement (ii) is correct. This defined grammar is form of Chomsky Normal Form, which has maximum number of moves are (2n – 1).

So, option (B) is correct.

Quiz of this Question


  • Last Updated : 11 Nov, 2018

Share your thoughts in the comments