Let G = ({S}, {a, b} R, S) be a context free grammar where the rule set R is S…

2003

Let G = ({S}, {a, b} R, S) be a context free grammar where the rule set R is S → a S b | SS | ε Which of the following statements is true?

  1. A.

    G is not ambiguous

  2. B.

    There exist x, y, ∈ L (G) such that xy ∉ L(G)

  3. C.

    There is a deterministic pushdown automaton that accepts L(G)

  4. D.

    We can find a deterministic finite state automaton that accepts L(G)

Attempted by 12 students.

Show answer & explanation

Correct answer: C

Summary: The grammar generates the language of balanced sequences of 'a' and 'b' (think of 'a' as '(' and 'b' as ')').

  • Language description: S → a S b produces matching (nested) pairs; S → SS allows concatenation of well-formed pieces; ε permits the empty string. So L(G) = all well-formed (balanced) sequences of a's and b's.

  • Ambiguity: The grammar is ambiguous because S → SS is a binary concatenation. Different binary groupings of several concatenated balanced blocks give distinct parse trees for the same string. For example, the string "ababab" (three unit pairs) can be parsed with different binary groupings of SS, hence multiple parse trees exist.

  • Deterministic pushdown automaton (DPDA) sketch: Use a stack to match a with b. On input 'a' push a stack symbol; on input 'b' pop one symbol if available; if a 'b' appears when the stack is empty, the automaton rejects; accept when the input is fully read and the stack is empty. This DPDA is deterministic because the action for each input symbol is uniquely determined by the symbol and the top-of-stack (no nondeterministic choices are needed).

  • Non-regularity: The language contains strings of the form a^n b^n (from nested uses of S → a S b). Such a pattern cannot be recognized by any finite-state automaton, so the language is not regular.

  • Concatenation property: Because of S → SS, concatenating any two strings from L(G) yields a string still in L(G); there are no x, y in L(G) for which xy is outside L(G).

Conclusion: The statement that a deterministic pushdown automaton accepts L(G) is true. The statements claiming the grammar is not ambiguous, claiming there exist x,y in L(G) with xy not in L(G), or claiming a deterministic finite automaton can accept L(G) are all false for the reasons given above.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir