Consider the following context-free grammars: \(G_1 : S \to aS \mid B, B \to b…

GATE · 2016 · CS · Set 1 · Computer Science & IT

Consider the following context-free grammars:

\(G_1 : S \to aS \mid B, B \to b \mid bB\)

\(G_2 : S \to aA \mid bB, A \to aA \mid B \mid \varepsilon,B \to bB \mid \varepsilon\)

Which one of the following pairs of languages is generated by \(G_1\) and \(G_2\), respectively?

  1. A.

    \(\{ a^mb^n \mid m > 0 \text{ or } n >0\}\) and \(\{ a^mb^n \mid m > 0 \text{ and } n >0\}\)

  2. B.

    \(\{ a^mb^n \mid m > 0 \text{ and } n >0\}\) and \(\{ a^mb^n \mid m > 0 \text{ or } n\geq0\}\)

  3. C.

    \(\{ a^mb^n \mid m \geq 0 \text{ or } n >0\}\) and \(\{ a^mb^n \mid m > 0\text{ and } n>0\}\)

  4. D.

    \(\{ a^mb^n \mid m \geq 0 \text{ and } n >0\}\) and \(\{ a^mb^n \mid m > 0 \text{ or } n>0\}\)

Attempted by 99 students.

Show answer

Correct answer: D

The worked solution is available to enrolled students.

Video solution available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…