# Is the following PDA a DPDA or NPDA?

Let the language be : $$L = \{ w \in \{a,b\}^* : \#_a(w) = \#_b(w)\}.$$ Now the PDA that I've designed for this language and seen at many other places is :

Let the PDA be denoted by M such that,
M = ({q0,q1}, {a,b}, {z0, a,b}, q0, delta, z0, q1)

Transitions for accepting L:
delta(q0, a, z0) = (q0, az0)
delta(q0, a, a)  = (q0, aa)
delta(q0, b, z0) = (q0, bz0)
delta(q0, b, b)  = (q0, bb)
delta(q0, a, b)  = (q0, epsilon)
delta(q0, b, a)  = (q0, epsilon)
delta(q0, epsilon, z0) = (q1, z0)


Now, if a PDA has to be termed as DPDA, then it should follow the following 2 properties strictly :

 1. delta(q, a, b) will contain atmost 1 element
2. if delta(q, epsilon, b) != empty_set
then, for every input symbol c on state q,
delta(q, c, b) == empty_set should hold true


Source : An Introduction To Formal Languages And Automata 6th Edition, Peter Linz

But the above mentioned PDA contains the following 2 transitions that violate the second condition:

delta(q0, epsilon, z0) = (q1, z0)
delta(q0, a, z0) = (q0, az0)
delta(q0, b, z0) = (q0, bz0)


Issue : According to my understanding of DPDA, this PDA should be a NPDA. But at few places I've seen this PDA marked as DPDA, which I feel is wrong. So can you help me clear this doubt?

• Your PDA is not deterministic, but it can be turned into one. You should have a way of detecting that you're at an accepting position. – Yuval Filmus Oct 27 '19 at 18:30
• The accepting position as in the accepting criteria? According to me, the string will be accepted whenever all of it's symbols have been read and the stack contains only the stack start symbol. Is it correct? – Argon Oct 28 '19 at 0:49
• Accepting position means having encountered an identical number of a’s and b’s. – Yuval Filmus Oct 28 '19 at 5:32
• You wrote delta(q0, b, bb) = (q0, bb), is this a typo? – Christopher Boo Oct 28 '19 at 12:23
• @ChristopherBoo Yes, it was a typo. Made the edit. Thanks for the correction. – Argon Oct 28 '19 at 12:31