Multiple choice

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 $\rightarrow$$\in$ Î and A $\rightarrow$ a) to parse a string with n tokens?

  1. n/2

  2. n-1

  3. 2n-1

  4. 2n

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

2 × (4) − 1 = 7 reductions $\Rightarrow$2n − 1 reductions are required. [Note: Unit production is given as A $\rightarrow$ a, it was typo] Above reductions are not in reverse of RMD but when they are reduced in bottom-up parsing, we will get same number of reductions.