GATE CS 2016, set 1 · Question 52 · Theory of Computation · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

Consider the following context-free grammars:
G₁: S → aS | B, B → b | bB
G₂: S → aA | bB, A → aA | B | ε, B → bB | ε
Which one of the following pairs of languages is generated by G₁ and G₂, respectively?

  1. (A) {aᵐ bⁿ | m > 0 or n > 0} and {aᵐ bⁿ | m > 0 and n > 0}
  2. (B) {aᵐ bⁿ | m > 0 and n > 0} and {aᵐ bⁿ | m > 0 or n ≥ 0}
  3. (C) {aᵐ bⁿ | m ≥ 0 or n > 0} and {aᵐ bⁿ | m > 0 and n > 0}
  4. (D) {aᵐ bⁿ | m ≥ 0 and n > 0} and {aᵐ bⁿ | m > 0 or n > 0}
Answer

Answer (D)

Answer from the official GATE CS 2016 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes