StreakPeaked· Practice

ExamsGATETechnical

Consider the following context-free grammar where the set of terminals is {a, b, c, d, f}: S → daT | Rf T → aS | baT | ε R → caTR | ε Which of the following is correct?

  1. The language generated by the grammar is finite.
  2. The language generated by the grammar contains the string daabaf.
  3. The language generated by the grammar contains the string cad aaf.
  4. The language generated by the grammar contains the string cacadaaf.

Correct answer: The language generated by the grammar contains the string daabaf.

Solution

Starting from S → daT, choose T → aS and then S → Rf with R → ε, or more directly use T → baT and then ε to build the required pattern. The string daabaf can be generated by appropriate substitutions, so the language contains it.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →