Skip to content
Official PYQ · 2003

GATE CS 2003 Q51 — Context-free Grammars and Push-down Automata

Explain with AI

Let G=({S},{a,b},R,S)G=\left(\left\{S\right\}, \left\{a,b\right\},R,S\right) be a context free grammar where the rule set R is S→aSb∣SS∣ϵS \to a S b \mid S S \mid \epsilon

Which of the following statements is true?

Choose one option
View worked solution

Answer: C

The given grammar is:

S→aSb∣SS∣ϵS \to aSb \mid SS \mid \epsilon

This grammar generates the language L(G)L(G) of balanced parentheses (often called the Dyck language D1D_1), where aa represents the opening parenthesis and bb represents the closing parenthesis.

Let's analyze each option:

  • Option A: GG is not ambiguous
    The grammar is highly ambiguous. For example, the string ϵ\epsilon has multiple derivations:
    1. S⇒ϵS \Rightarrow \epsilon
    2. S⇒SS⇒ϵϵ=ϵS \Rightarrow SS \Rightarrow \epsilon\epsilon = \epsilon
    Hence, GG is ambiguous. This statement is false.
  • Option B: There exist x,y∈L(G)x, y \in L(G) such that xy∉L(G)xy \notin L(G)
    Since the grammar contains the rule S→SSS \to SS, if x∈L(G)x \in L(G) and y∈L(G)y \in L(G), we can derive xyxy starting from SS via S→SS⇒∗xyS \to SS \Rightarrow^* xy. Thus, L(G)L(G) is closed under concatenation, meaning xy∈L(G)xy \in L(G) for all x,y∈L(G)x, y \in L(G). This statement is false.
  • Option C: There is a deterministic pushdown automaton that accepts L(G)L(G)
    The language of balanced parentheses is a well-known Deterministic Context-Free Language (DCFL). A Deterministic PDA (DPDA) can accept it by pushing aa onto the stack and popping aa when bb is encountered. If the stack is empty at the end of the input, the string is accepted. This statement is true.
  • Option D: We can find a deterministic finite state automaton that accepts L(G)L(G)
    The language L(G)L(G) requires matching an arbitrary number of nested aa's and bb's, which requires infinite memory. Since it is not a regular language, no DFA can accept it. This statement 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