Skip to content
Official PYQ · 2017

GATE CS 2017 Set 2 Q16 — Context-free Grammars and Push-down Automata

Explain with AI

Identify the language generated by the following grammar, where SS is the start variable.

  • S→XYS \rightarrow XY
  • X→aX∣aX \rightarrow aX \mid a
  • Y→aYb∣ϵY \rightarrow aYb \mid \epsilon
Choose one option
View worked solution

Answer: C

To find the language generated by the given grammar, let us analyze the languages generated by the non-terminals XX and YY individually:

  1. Language generated by XX:

    The production rules for XX are:

    X→aX∣aX \rightarrow aX \mid a

    This generates one or more aa's. Thus,

    L(X)={ak∣k≥1}L(X) = \{a^k \mid k \geq 1\}
  2. Language generated by YY:

    The production rules for YY are:

    Y→aYb∣ϵY \rightarrow aYb \mid \epsilon

    This generates equal numbers of aa's followed by bb's, including the empty string. Thus,

    L(Y)={anbn∣n≥0}L(Y) = \{a^n b^n \mid n \geq 0\}

Since the start symbol SS has the production S→XYS \rightarrow XY, the language L(S)L(S) is the concatenation of L(X)L(X) and L(Y)L(Y):

L(S)=L(X)⋅L(Y)L(S) = L(X) \cdot L(Y) L(S)={akanbn∣k≥1,n≥0}L(S) = \{a^k a^n b^n \mid k \geq 1, n \geq 0\} L(S)={ak+nbn∣k≥1,n≥0}L(S) = \{a^{k+n} b^n \mid k \geq 1, n \geq 0\}

Let m=k+nm = k + n. Since k≥1k \geq 1, we have:

m−n≥1  ⟹  m>nm - n \geq 1 \implies m > n

Since n≥0n \geq 0, the language can be written as:

L(S)={ambn∣m>n,n≥0}L(S) = \{a^m b^n \mid m > n, n \geq 0\}

Therefore, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Context-free Grammars and Push-down Automata questions