Docsity

Pushdown Automata PDAs - Lecture Notes | CSCI 2400, Study notes of Computer Science

Partial preview of the text

Download Pushdown Automata PDAs - Lecture Notes | CSCI 2400 and more Study notes Computer Science in PDF only on Docsity!

Pushdown Automata

PDAs

Pushdown Automaton -- PDA

Input String

Stack

States

The States

q

1

q

2

a, b  c

Input

symbol

Pop

symbol

Push

symbol

q

1

q

2

a, b  c

a  

b

top

input

stack

a  

Replace

e

h

e

h

c

q

1

q

2

a, b  

a  

a  

Pop

b

e

h

e

h

top

input

stack

q

1

q

2

a,   

a  

a  

No Change

b

e

h

e

h

b

top

input

stack

q

1

q

2

a , $  b

a  

a  

Pop

top

input

stack

A Possible Transition

b

Non-Determinism

q

1

q

2

a, b  c

q

3

a, b  c

q

1

q

2

, b  c

  transition

PDAs are non-deterministic

Allowed non-deterministic transitions

,   

a,   a b, a  

q 0 q 1 q 2 q 3

b, a  

, $  $

L ( M ) { a b : n  0 } n n Basic Idea: Push the a’s on the stack

  1. Match the b’s on input

with a’s on stack

  1. Match

found

a,   a

b, a  

0

q

q

1

q

2

q

3

Execution Example:

Input

a a a

b b b

current

state

b, a  

Time 0

Stack

a,   a

b, a  

q

0

q

1

q

2

q

3

Input

Stack

a a a

b b b

a

b, a  

Time 2

a,   a

b, a  

q

0

q

1

q

2

q

3

Input

Stack

a a a

b b b

a

a

b, a  

Time 3

a,   a

b, a  

q

0

q

1

q

2

q

3

Input

a a a

b b b

Stack

a

a

a

b, a  

Time 5

a,   a

b, a  

q

0

q

1

q

2

q

3

Input

a a a

b b b

a

Stack

b, a  

Time 6

a