Open In App

Difference Between NPDA and DPDA

Last Updated : 07 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

A Pushdown Automata (PDA) is a way to implement context-free Grammar in a similar way. We design Finite Automata for Regular Grammar.

  1. It is more powerful than FSM.
  2. FSM has very limited memory but PDA has more memory.
  3. PDA= Finite State Machine + Stack

This stack has infinite memory and that facilitates the higher power of Pushdown automata. This helps PDA to behave more powerful than Finite-state Machine.

A Pushdown Automata has three Components:

  1. An input tape
  2. A finite Control Unit.
  3. A stack with infinite size.

Definition of DPDA and NPDA with example

Let M = (Q,?,?,q0, Z,F ,?) be a PDA. The PDA is deterministic if and only if

  1. ?(q, a,  Z) has one element.
  2. If ?(q, ?,  Z) is non-empty, then ?(q, c,  Z) should be empty for every c ? ? .

Both conditions should be satisfied for the PDA to be deterministic. If one of the conditions fails, the PDA is non-deterministic.

Let us consider an example to understand more clearly.

Example: Is the PDA corresponding to the language L = {anbn | n>=1} by the finite state is deterministic ?

Solution: The shown transitions defined for this machine are shown below:

?(q0, a,  Z0) =?(q0, aZ0) 
?(q0, a, a) =?(q0, aa)
?(q0, b, a) =?(q1, ?)
?(q1, b, a) =?(q1, ?)
?(q1, ?, Z0) =?(qf, ?)

The PDA should satisfy the two conditions. shown in the definition to be deterministic.

  1. ?(q0, a,  Z0) has only one element. In this case, for each q?Q, a?? , and Z??, there exists only one definition so the first condition is satisfied.
  2. To satisfy the second condition consider the transition. ?(q1,? ,  Z0) = (qf,?,). Since the transition is defined, the transition ?(q, a,  Z0) where a?? should not be defined which is true.

since both conditions. are satisfied, then the given PDA is deterministic.

Difference between NPDA and DPDA:

S. No DPDA(Deterministic Pushdown Automata) NPDA(Non-deterministic Pushdown Automata)
1. It is less powerful than NPDA.

Example:

We can only construct DPDA for odd-length palindromes and not for even length palindromes.

It is more powerful than DPDA.

Example:

NPDA can be constructed for both even-length and odd-length palindromes.

2. It is possible to convert every DPDA to a corresponding NPDA. It is not possible to convert every NPDA to a corresponding DPDA.
3. The language accepted by DPDA is a subset of the language accepted by NDPA. The language accepted by NPDA is not a subset of the language accepted by DPDA.
4. The language accepted by DPDA is called DCFL(Deterministic Context-free Language) which is a subset of NCFL(Non-deterministic Context-free Language) accepted by NPDA. The language accepted by NPDA is called NCFL(Non-deterministic Context-free Language).

5.

There is only one state transition from one state to another state for an input symbol.

There may or maynot be more than one state transition from one state to another state for same input symbol.

There is one more difference as follows:
 

DPDA: For every input with the current state, there is only one move.

            M = (Q,?,?,q0, Z,F ,?)

            ?: Q*?*??Q*?*

Deterministic path

Deterministic path

NPDA: For every input with the current state, We can have multiple moves.

            M = (Q,?,?,q0, Z,F ,?)

            ?: Q*{???}*??2Q*?*

Non- Deterministic path

Why NPDA is more powerful than DPDA?

NDPA is more powerful than DPDA because we can add more transitions to it. It is possible for every language to add a transition. For some languages, we can construct DPDA there exist an NPDA but there are some languages that are accepted by NPDA but are not by DPDA. This is said to be powerful when it accepts more sets of languages than other automata. 

In fact, it is more powerful than DFA(Deterministic finite automata) and NFA(Non-deterministic finite automata) also because, In the case of DFA and NFA, they are equivalent in power. So for every language accepted by DFA there exist an NFA and Vice-Versa. There is not any language for which we construct NFA but not DFA. Hence, we can’t convert NPDA to DPDA always and we can convert NFA to equivalent DFA always.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads