PDA with differentiate
DPDA vs NPDA
Presented by
Group- 6
PUSH DOWN AUTOMATA
• A Pushdown Automata (PDA) is a way to implement a Context-
Free Grammar in a similar manner to how we design Finite
Automata for a Regular Grammar.
• Pushdown automata are similar to Nondeterministic Finite
Automata, but they have an additional component called a
Stack.
• Recognizes Context-Free Languages (CFLs).
• More powerful than FA but less than a Turing Machine.
Formal Definition
Properties of Pushdown
Automata
• It is more powerful than Finite State Machine (FSA).
• FSA has a very limited memory but PDA has more
memory.
• PDA = Finite State Machine + Stack.
Stack
• A stack is a way we arrange elements one on top of
another.
• A stack does two basic operations:
1. PUSH: A new element is added at the top of
the stack.
2. POP: The top element of the stack is read
and removed.
Components of Pushdown
Automata
• An Input tape.
• A Finite Control Unit.
• A Stack with infinite
size.
Graphical Notation (PDA)
Example
DETERMINISTIC PDA
• DPDA (Deterministic Pushdown Automaton)
is a type of Pushdown Automaton (PDA)
where for every state, input symbol, and
top of stack, there is at most one possible
DPDA (Deterministic Pushdown Automaton) is a type of Pushdown Automaton (PDA) where for every state, input symbol, and top of
move. stack, there is at most one possible move
• At every step, only one possible move
• No ε-transitions that cause confusion
• Each combination of (state, input, stack
top) → at most one move
• Accepts deterministic CFLs (DCFLs)
EXAMPLE DPDA
q0 (Start + Final also, double circle):
Transition: (a, λ ->a) -> If input a, with nothing on stack (λ), push a.
Then move to q1.
q1:
(a, λ ->a) ->On input a, push an a on stack (keeps counting number of a’s).
(b, a-> λ) ->On input b, if top of stack has a, pop that a.
When b starts, machine moves to q2.
q2:
(b, a -> λ) ->For each b, pop one a.
When input finishes and only $ remains in stack, move to q3.
q3 (Final State):
(λ, $-> $)-> Accepts if stack has only bottom symbol left
This DPDA accepts L = { aⁿ bⁿ | n ≥ 1 } -> equal number of a’s followed by equal number of b’s.
NON-DETERMININSTIC PDA
• Can have multiple possible moves for the same
configuration
• Can use ε-transitions freely
• Accepts all CFLs
• More powerful than DPDA
EXAMPLE NPDA
Start in the initial state with the stack containing only the
bottom-of-stack marker, $.
• For each 'a' read, push an X onto the stack.
• When a 'b' is read, the machine non-deterministically
chooses one of two paths.
• If the 'b' is the center of the palindrome, transition to the
second state and begin popping.
• If the 'b' is part of the first half, continue pushing Xs onto
the stack.
• For each 'b' read after the center, pop an X from the
stack.
The string is accepted if and only if the machine reaches the
final state with an empty stack (meaning only the $ remains).
This signifies a perfect match between the first and second
halves of the palindrome.
DPDA VS NPDA
Feature DPDA NPDA
Determinism Only one move possible Multiple moves possible
ε-transitions Restricted / limited Freely allowed
Languages Deterministic CFLs (subset of
All CFLs
accepted CFLs)
Power Less powerful More powerful
Example a^nb^n Palindrome
APPLICAION OF PDA
• Checking balanced parentheses
• Recognizing context-free languages
• Natural language processing
Summary
• PDA = FA + Stack → accepts Context-Free Languages
(CFLs)
• DPDA → Deterministic, single move only, restricted ε-
transitions, accepts DCFLs
• NPDA → Non-deterministic, multiple moves, free ε-
transitions, accepts all CFLs
• Power: DPDA ⊂ NPDA (DPDA less powerful)
• Examples:
• DPDA → { aⁿbⁿ }
• NPDA → Palindromes
THANK YOU