The grammar S → aB / bA A → a / aS / bAA B → b / bS / aBB

2012

The grammar

S → aB / bA
A → a / aS / bAA
B → b / bS / aBB

  1. A.

    Generates an equal number of a’s and b’s

  2. B.

    Generates an inherently ambiguous language

  3. C.

    Generates more a’s than b’s

  4. D.

    Generates an unequal number of a’s and b’s

Attempted by 110 students.

Show answer & explanation

Correct answer: A

The grammar ensures balanced terminals. S produces equal a's and b's by combining A (one extra a) with B (one extra b). Base cases A→a and B→b establish the offset, while recursive rules maintain equality.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor