Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the context free Grammar with 7 (seven) productions.

S \(\rightarrow\) Aa / B
B \(\rightarrow\) A / bb
A \(\rightarrow\) a / bc / B

After removing all unit productions the resulting equivalent grammar will contain ................................. productions.

  • A.18
  • B.12
  • C.10
  • D.11

Answer: C

The resulting grammar has 10 productions.

The unit productions are S \(\to\) B, B \(\to\) A and A \(\to\) B, so B and A can each derive the other, and S can derive both. Removing them, each variable takes the non-unit productions of every variable it can reach through unit productions. The non-unit productions are S \(\to\) Aa, B \(\to\) bb and A \(\to\) a | bc.

  • S \(\to\) Aa | bb | a | bc: 4 productions
  • B \(\to\) bb | a | bc: 3 productions
  • A \(\to\) a | bc | bb: 3 productions

That makes 4 + 3 + 3 = 10. Counts such as 11, 12 or 18 come from keeping a unit production or duplicating a substituted one.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.