Question

Consider the transition diagram of a PDA given below with input alphabet Σ={a,b}\Sigma = \{a, b\} and stack alphabet Γ={X,Z}\Gamma = \{X, Z\}. ZZ is the initial stack symbol. Let LL denote the language accepted by the PDA.

State transition diagram of a pushdown automaton with input alphabet {a, b} and stack alphabet {X, Z}, where Z is the initial stack symbol. The start state q0 is an accept state (double circle) with a self-loop labeled 'a, X/XX' and 'a, Z/XZ'. A transition from q0 to q1 is labeled 'b, X/epsilon'. State q1 has a self-loop labeled 'b, X/epsilon' and transitions to accept state q2 (double circle) on 'epsilon, Z/Z'.
PDA transition diagram

Which one of the following is TRUE?

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2016 answer key

Solution

Trace the behavior of the PDA on inputs to determine the accepted language and verify whether the transition relation satisfies determinism.

Examine the transitions of the PDA:

  • Initial state is q0q_0 with stack bottom marker ZZ. State q0q_0 is an accepting state (double circle).
  • On input aa in state q0q_0: (q0,a,Z)→(q0,XZ)(q_0, a, Z) \to (q_0, XZ) and (q0,a,X)→(q0,XX)(q_0, a, X) \to (q_0, XX). Each aa pushes an XX onto the stack.
  • Since q0q_0 is an accepting state, any sequence of aa's alone is accepted by entering no further transitions. Thus, {an∣n≥0}⊆L\{a^n \mid n \ge 0\} \subseteq L.

Transitions involving bb:

  • From q0q_0, on input bb with XX on top: (q0,b,X)→(q1,ε)(q_0, b, X) \to (q_1, \varepsilon), popping one XX.
  • In state q1q_1, on input bb with XX on top: (q1,b,X)→(q1,ε)(q_1, b, X) \to (q_1, \varepsilon), popping one XX for each bb.
  • From q1q_1, on ε\varepsilon with ZZ on top: (q1,ε,Z)→(q2,Z)(q_1, \varepsilon, Z) \to (q_2, Z), reaching accepting state q2q_2.
  • State q2q_2 has no outgoing transitions. It is reached if and only if the number of bb's matches the number of aa's that were pushed on the stack (nn occurrences of aa followed by nn occurrences of bb).
    Therefore, strings of the form anbna^n b^n for n≥1n \ge 1 (and n=0n=0 at q0q_0) are accepted.

Total accepted language:

L={an∣n≥0}∪{anbn∣n≥0}L = \{a^n \mid n \ge 0\} \cup \{a^n b^n \mid n \ge 0\}

Checking for determinism (DPDA):

  • In state q0q_0: transitions are defined for (a,Z)(a, Z), (a,X)(a, X), and (b,X)(b, X). There are no ε\varepsilon-transitions from q0q_0, and each input/stack combination has at most one choice.
  • In state q1q_1: transition on input bb requires stack top XX, while the ε\varepsilon-transition requires stack top ZZ. Because the stack symbols XX and ZZ are disjoint, there is never a choice between reading an input symbol and taking an ε\varepsilon-move.
  • In state q2q_2: no transitions exist.
    Since every configuration has at most one valid move, the PDA is deterministic. Hence, LL is a deterministic context-free language (DCFL).
Final answer

D

Common trap

Assuming that having an epsilon transition from q1q_1 makes the PDA non-deterministic, ignoring that the epsilon transition requires stack symbol ZZ while the bb-loop requires stack symbol XX.

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

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 1
Question
53 of 65, printed as CS Q.43
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.