





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






































1
2
18
By general principles, can carry out any
recursive computation on a stack. Can do it on a restricted version of an activation record stack, called a “ P ush d own (Stack) A utomaton” or PDA for short.
Q: What is the language generated by
S # | aSa | bSb?
19
A: Palindromes in {a,b,#}* containing
exactly one #-symbol.
Q: Using a stack, how can we recognize
such strings?
21
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
22
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
Input:
aaab#baa
24
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
a a
Input:
aaab#baa
25
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
a a a
Input:
aaab#baa
27
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
b a a a
Input:
aaab#baa
28
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
a a a
Input:
aaab#baa
30
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
a
Input:
aaab#baa REJECT (nonempty stack)
31
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
a a
Input:
aaab#baaa
33
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
Input:
aaab#baaa Pause input
34
Push it
read #? (ignore stack)
read == peek? Pop Else: CRASH!
empty stack?
Input:
aaab#baaa ACCEPT