CS373 – Fall 2003 – NMG
*************Solutions ********************+
October 27, 2003
Homework Assignment 7 for chapter 7
Due 10/31/03 (Friday) at end of class
Problems related to chapter 7.
Unless otherwise noted you are to assume the conventions and definitions used
in our text by Linz
for push down automata and related topics.
If you must write the
δ
rules for a pushdown
automaton, write concise, clear comments to the right of the transition rules (as needed) explaining the meaning
and intent of the rules.
1.
Construct an NPDA that
accepts L = {w : n
a
(w) + n
b
(w) = n
c
(w)}.
2.
Construct an NPDA that
accepts L = {a
3
b
n
c
n
: n
≥
0}.
3.
Construct an NPDA that
accepts L = {a
n
b
n+m
c
m
: n
≥
0, m > 0 }.
4.
Consider
the following “mystery” NPDA:
δ
(s, a, z) = {s, cz}
δ
(s, a, c) = {s, cc}
δ
(s, b, z) = {(s, cz), (r, z)}
δ
(s, b, c) = {(s, cc), (r, c)}
δ
(r, a, c) = {r,
λ
}
δ
(r, b, c) = {r,
λ
}
δ
(r,
λ
, z) = {f, z}
where Q = {s, r, f},
∑
= {a,b},
Γ
= {c, z},
F (final state) = {f}
Determine if the following strings are accepted or not.
Show the
sequences of instantaneous
transitions for accepted strings, or give a convincing argument for those not accepted.
From this exercise or analysis of the rules, state the language accepted by this NPDA in set
theoretic notation; give a convincing reason for your choice of language.
a
b
aababaaab
baaabbaab
aabbabbaa
abbbabbbb
State the language accepted by this NPDA in set theoretic notation.
5.
An alternate definition of an NPDA is a modification of the definition given by Linz.
The alternate
definition allows a
λ
to appear as the third argument of
δ
(top of the stack).
The meaning of
λ
in
this position is that the stack top is ignored as an input to
δ
and consequently nothing is popped off.
Also only one symbol at a time may be pushed on the stack as opposed to a string of symbols in the
Linz definition.
In addition, there is no end of stack symbol (z) as in Linz.
All computations start