• edited by
25,131 views
40 40 votes

Which of the following languages is accepted by a non-deterministic pushdown automaton (PDA) but NOT by a deterministic PDA?

  1. $\{a^nb^nc^n \mid n ≥ 0\}$
  2. $\{a^lb^mc^n \mid l ≠ m \text{ or } m ≠ n\}$
  3. $\{a^nb^n \mid n ≥ 0\}$
  4. $\{a^mb^n \mid m, n ≥ 0\}$

4 Answers

Best answer
40 40 votes

Ooption B is correct.

 $L = \{a^lb^mc^n \mid l ≠ m \text{ or } m ≠ n\}$

$(q_0,a,Z_0) \rightarrow (q_0,aZ_0)$

($q_0,a,a) \rightarrow (q_0,aa)$

$(q_0,b,a) \rightarrow (q_1,\epsilon), (q_2,ba) $

[here it is NPDA where we have to check $l\neq m$ or $m\neq n$; for $l\neq m$ we need to pop $a$ for $b$; for $m\neq n$ we need to keep $b$ in stack so that we can pop $b$ for $c$  ]

$(q_1,b,a) \rightarrow (q_1,\epsilon)$

$(q_1,c,a) \rightarrow (q_f,\epsilon)$

$(q_1,b,Z_0) \rightarrow (q_f,\epsilon)$

$(q_2,b,b) \rightarrow q_2,bb)$

$(q_2,c,b) \rightarrow (q_3,\epsilon)$

$(q_3,c,b) \rightarrow (q_3,\epsilon)$

$(q_3,c,a) \rightarrow (q_f,\epsilon)$

$(q3,\epsilon,b) \rightarrow (q_f,\epsilon)$

(A) is wrong as it is not context free

(D)  $a^*b^*$ is regular, so must have DFA , and so an equivalent DPDA

(C) can be accepted using DPDA 

• edited by
17 17 votes

Option B.

At a time, the PDA can compare \large a\text{ and }b  or,  \large b\text{ and }c, but not both.

To compare both conditions at the same time, we need a NPDA.

In first case on seeing b pop

2 nd case on seeing b push

1 1 vote

Option A: $ \{ a^n b^n c^n \mid n \geq 0 \} $

This language is not context-free.  Proof via pumping lemma:

 Assume it is CFL. Let $ p $ be pumping length. Choose $ s = a^p b^p c^p $. Any decomposition $ s = uvxyz $ with $ |vxy| \leq p $, $ |vy| \geq 1 $ will fail when pumped  e.g., if $ vxy $ lies in $ a^p $, pumping up increases $ a $’s only → breaks balance. Similarly for other cases.  

  • Not CFL → not accepted by any PDA (deterministic or not).  
  • Eliminate A.

 

Option B: $ \{ a^l b^m c^n \mid l \ne m \text{ or } m \ne n \} $

This is the complement of $ \{ a^l b^m c^n \mid l = m = n \} $, which is not CFL. But complement of non-CFL may or may not be CFL.

This language can be written as:
$$
\overline{ \{ a^n b^n c^n \mid n \geq 0 \} } \cap \{ a^* b^* c^* \}
$$

But more directly: note that this language includes all strings in $ a^* b^* c^* $ except those where $ l = m = n $. Since the set of strings with $ l = m = n $ is not CFL, and CFLs are not closed under complement. But the language can be expressed as
$$
L = L_1 \cup L_2
$$
where  

  • $ L_1 = \{ a^l b^m c^n \mid l \ne m \} $  
  • $ L_2 = \{ a^l b^m c^n \mid m \ne n \} $

Each of these is context-free. For $ L_1 $: use a PDA that guesses whether $ l > m $ or $ l < m $, then checks accordingly. Similarly for $ L_2 $. Since CFLs are closed under union, $ L $ is CFL.

It is not deterministic because to check $ l \ne m $, you must guess whether $ l > m $ or $ l < m $, which requires non-determinism. Similarly for $ m \ne n $. There is no way for a DPDA to decide deterministically which inequality holds without backtracking.  It is not a DCFL.

Option C: $ \{ a^n b^n \mid n \geq 0 \} $

This is the classic example of a DCFL.  

  • A DPDA can:
  • Push $ a $’s onto stack,
  • Pop one $ a $ for each $ b $,
  • Accept if stack empty at end.

No guessing needed → DCFL.So it is accepted by a DPDA → does not satisfy “NOT by a DPDA”.

 

Option D: $ \{ a^m b^n \mid m, n \geq 0 \} $

This is $ a^* b^* $, which is regular, hence certainly DCFL (in fact, even accepted by a DFA).

 

$$
\color{lime} \boxed{\text{Answer:B}}
$$

• edited by
1 flag:
✌ Edit necessary (rivyth “Wrong NPDA”)
Answer:
Position:
Show:

Related questions

42 42 votes
5 answers 5 answers
14.2k
14.2k views
Ishrat Jahan asked Oct 31, 2014
14,157 views
Consider the pushdown automaton (PDA) below which runs over the input alphabet $(a, b, c)$. It has the stack alphabet $\{Z_0, X\}$ where $Z_0$ is the bottom-of-stack mark...
56 56 votes
4 answers 4 answers
18.2k
18.2k views
Ishrat Jahan asked Nov 1, 2014
18,233 views
Let $L$ be a regular language. Consider the constructions on $L$ below:$\text{repeat} (L) = \{ww \mid w \in L\}$$\text{prefix} (L) = \{u \mid \exists v : uv \in L\}$$\tex...
40 40 votes
3 answers 3 answers
16.0k
16.0k views
Ishrat Jahan asked Nov 1, 2014
16,034 views
Let $L$ be a regular language. Consider the constructions on $L$ below:repeat $(L) = \{ww \mid w \in L\}$prefix $(L) = \{u \mid ∃v : uv \in L\}$suffix $(L) = \{v \mid ...
64 64 votes
5 answers 5 answers
14.4k
14.4k views
Ishrat Jahan asked Oct 31, 2014
14,440 views
For a state machine with the following state diagram the expression for the next state $S^+$ in terms of the current state $S$ and the input variables $x$ and $y$ is$S^+ ...