LL grammar for the language L = { aⁿ bᵐ cⁿ⁺ᵐ | m ≥ 0, n ≥ 0 } is

2013

LL grammar for the language
L = { aⁿ bᵐ cⁿ⁺ᵐ | m ≥ 0, n ≥ 0 } is

  1. A.

    S → aSc | S₁
    S₁ → bS₁c | λ

  2. B.

    S → aSc | S₁ | λ
    S₁ → bS₁c

  3. C.

    S → aSc | S₁ | λ
    S₁ → bS₁c | λ

  4. D.

    S → aSc | λ
    S₁ → bS₁c | λ

  5. E.

    A and C both

Attempted by 42 students.

Show answer & explanation

Correct answer: E

The language L = { aⁿ bᵐ cⁿ⁺ᵐ } requires matching n 'a's with the last n 'c's and m 'b's with the intermediate c's. We construct S → aSc | B to handle 'a' and outer 'c', while B → bBc | ε handles the 'b's. This ensures LL(1) compliance by distinguishing start symbols.

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

Explore the full course: Mppsc Assistant Professor