GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 7(b)

Exponents generated by a recursive grammar

Theory of Computation · Context-Free Grammars & Languages · Full GATE CSE 2000 paper

GATE 2000, Q7(b) Descriptive
Report issue

Context-Free Grammars & Languages

Question 7(b), GATE 2000: Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.

Task: Determine the exact condition on i,j.
Question 7(b), GATE 2000: Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.

Task: Determine the exact condition on i,j.
Tap to enlarge
Shared context

Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.

Answer & solution

Answer: (i,j)=(0,0), or i≥1 and j≥i. (no official key was published)

1. Every application of S→aSAb adds one a at the front and one mandatory b at the end, with an A that can generate any additional number of b symbols.

2. After i recursive applications and S→ε, the form is aⁱ(Ab)ⁱ. Thus j=i+k₁+⋯+kᵢ for arbitrary nonnegative integers k₁,…,kᵢ.

3. If i≥1, this gives j≥i. Every such j is attainable by assigning j−i extra b symbols to one A and zero to all the others.

4. If i=0, S goes directly to ε and there are no A symbols, so j must also be zero. The looser answer j≥i incorrectly includes nonempty strings consisting only of b.

Original paper, page 7