CS 341 Automata Theory
Elaine Rich
Homework 9
Answers
1)
Build a
deterministic
PDA that accepts
L
$, where
L
= {
w
∈
{
a
,
b
}* : #
a
(
w
) = #
b
(
w
)}.
The idea is to use a bottom of stack marker so that
M
can tell what it should be counting.
If the top of the stack is an
a
, it is counting
a
’s.
If the top of the stack is a
b
, it is counting
b
’s.
If the top of the stack is #, then it isn’t counting
anything yet.
So if it is reading an
a
, it should start counting
a
’s.
If it is reading a
b
, it should start counting
b
’s.
M
= ({0, 1, 2}, {
a
,
b
}, {
a
,
b
}, 0, {2},
∆
), where
∆
=
{((0,
ε
,
ε
), (1, #)),
((1, $, #),(2,
ε
)),
/* starting and ending.
((1,
a
,
a
), (1,
aa
)),
((1,
b
,
a
), (1,
ε
)),
/* already counting
a
’s.
((1,
a
,
b
), (1,
ε
)),
((1,
b
,
b
), (1,
bb
)),
/* already counting
b
’s.
((1,