Question

Consider the following grammar where SS is the start symbol, and aa and bb are terminal symbols.

S→aSbS∣bS∣ϵS \rightarrow aSbS \mid bS \mid \epsilon

Which of the following statements is/are true?

Choose every correct option
Official answer and solution
Official answer
A, B and C
From
Official GATE 2026 answer key

Solution

Test derivations of abbabb and abababab under the given CFG and recall that every CFL is decidable.

  1. Options (A) and (B) are true: The string abbabb has two distinct leftmost derivations (and two distinct parse trees):
    • S⇒aSbS⇒abS⇒abbS⇒abbS \Rightarrow aSbS \Rightarrow abS \Rightarrow abbS \Rightarrow abb (where the first SS derives ϵ\epsilon and the second SS derives bb via bS⇒bbS \Rightarrow b)
    • S⇒aSbS⇒abSbS⇒abbS⇒abbS \Rightarrow aSbS \Rightarrow abSbS \Rightarrow abbS \Rightarrow abb (where the first SS derives bb via bS⇒bbS \Rightarrow b and the second SS derives ϵ\epsilon)
      Hence abbabb has two distinct derivations and the grammar is ambiguous.
  2. Option (C) is true: Every application of S→aSbSS \rightarrow aSbS introduces one aa and one bb, while S→bSS \rightarrow bS introduces an extra bb. Since abababab has two aa's and two bb's, the production S→bSS \rightarrow bS can never be used in deriving abababab. Restricting to S→aSbS∣ϵS \rightarrow aSbS \mid \epsilon (the unambiguous Dyck grammar), abababab has a unique parse tree and therefore only one rightmost derivation:
    S⇒rmaSbS⇒rmaSbaSbS⇒rmaSbaSb⇒rmaSbab⇒rmababS \Rightarrow_{\text{rm}} aSbS \Rightarrow_{\text{rm}} aSbaSbS \Rightarrow_{\text{rm}} aSbaSb \Rightarrow_{\text{rm}} aSbab \Rightarrow_{\text{rm}} abab
  3. Option (D) is false: Every context-free language is decidable.
Final answer

Options (A), (B), (C)

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
Question
25 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.