CS 390 Solutions to Homework 10


Textbook p. 240:

6.1(b) The palindromes of odd lengths over {a, b}.
(f) All strings of a's and b's that end in a.
When you need a's use S -> SS to get S's and change S's to a with S -> a.
When you need b's use S -> bS to get as many b's as you need.
You can generate strings of even or odd lengths.
You can never end a string with b becasue b is always follwed by S and S must eventually turn a.


Textbook pp. 290 - 291:

7.4 (b)
State Input Stack Move
q0 a a (q0, aa), (q1, a)
q0 a b (q0, ab), (q1, b)
q0 b a (q0, ba), (q1, a)
q0 b b (q0, bb), (q1, b)
q1 a a (q1, )
q1 b b (q1, )
q1 Z0 (q2, Z0)
q0 a Z0 (q0, aZ0)
q0 b Z0 (q0, bZ0)


Initial State: q0
Accepting State: q2

7.6 All strings over {a, b} that start and end in the same symbol.