Skip to content
Official PYQ · 2026

GATE CS 2026 Set 1 Q15 — Context-free Grammars and Push-down Automata

Explain with AI

Consider the following grammar where SS is the start symbol, and aa and bb are terminal symbols.
S→aSbS | bS | ϵS \rightarrow a S b S \text{ | } b S \text{ | } \epsilon
Which of the following statements is/are true?

Select all correct options
View worked solution

Answer: A;B;C

Let us analyze each option step-by-step:

  • Options A and B: A grammar is ambiguous if there exists a string with more than one distinct leftmost derivation (or parse tree). Let us find the leftmost derivations (LMD) for the string abbabb:
    1. LMD 1: S⇒aSbS⇒a(bS)bS⇒abSbS⇒ab(ϵ)bS⇒abb(ϵ)=abbS \Rightarrow aSbS \Rightarrow a(bS)bS \Rightarrow abSbS \Rightarrow ab(\epsilon)bS \Rightarrow abb(\epsilon) = abb
    2. LMD 2: S⇒aSbS⇒a(ϵ)bS⇒abS⇒ab(bS)⇒abb(ϵ)=abbS \Rightarrow aSbS \Rightarrow a(\epsilon)bS \Rightarrow abS \Rightarrow ab(bS) \Rightarrow abb(\epsilon) = abb
    Since abbabb has exactly two distinct derivations, Option A and Option B are both TRUE.
  • Option C: To generate the string abababab, the derivation must start with S→aSbSS \rightarrow aSbS. To match the prefix aa and the subsequent bb, the only valid partition is for the first SS to derive ϵ\epsilon and the second SS to derive abab (since any other choice leads to too many terminals or mismatched prefixes).
    The unique rightmost derivation (RMD) is: S⇒aSbS⇒aSbaSbS⇒aSbaSb⇒aSbab⇒ababS \Rightarrow aSbS \Rightarrow aSbaSbS \Rightarrow aSbaSb \Rightarrow aSbab \Rightarrow abab Since there is only one rightmost derivation for abababab, Option C is TRUE.
  • Option D: The given grammar is a Context-Free Grammar (CFG). The language generated by any CFG is a Context-Free Language (CFL), which is always decidable. Thus, Option D is FALSE.

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

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