Skip to content
GATEiit

GATE CSE 2017 Session 1 Q44: Which string is not generated by S → SaS | aSb | bSa | SS | ε

Syllabus topic: Context-free grammars and push-down automata

Question

If G is a grammar with productions

S→SaS∣aSb∣bSa∣SS∣ϵ

where S is the start variable, then which one of the following strings is not generated by G?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: D (official GATE 2017 final answer key)

Concept used: Find an invariant of the grammar: every production adds at least as many a's as b's, so every generated string has #a ≥ #b.

Concept notes

Loading notes…

First step: Look at how each production changes the count of a's and b's, then compare the counts in each option.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Context-free grammars and push-down automata

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 1 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key