You have 24-hours to finish this test.  The test must be returned by Friday at 5:00 at the latest.  You are allowed to use your text and your notes for this text, but no other references.  You are permitted to discuss this exam only with the instructor until after the Friday deadline.

1. Write a context-free grammar to generate all and only regular expressions over the alphabet {a, b}.

2.  A two-way DSA (2DSA) is a DSA that is permitted to move either way on its input.  It accepts by moving off the right end of its input in a final state.  Show that L={anbncn where n>= 1} is accepted by a 2DSA.  What can we conclude about 2DSAs versus DSAs?  Would an 2TM be more powerful than a TM?  Give an informal argument jusifying your answer.

3.  Suppose we have a DSA which limits the stack size to 100 elements.  Give an informal argument that the DSA can only accept regular languages.

4.  A submarine travels under the Euclidean plane with constant velocity (speed and direction).  Every hour on the hour it passes under a point (x, y) where x and y are integers.  Also every hour, on the hour, you take a sonar sounding at a point of your choosing to determine if you found the sub.  You cannot see the submarine and you do not know its initial position and velocity.  Describe a strategy you can use to determine the location of the submarine.  (HINT:  Consider the "shoelacing" technique we discussed in recursively enumerating the output of Turing machines and in discussing the Cardinality of sets).

5.  TRUE/FALSE questions:

a)  The proof to the halting problem implies that you can never tell if a given program will halt.
b)  A Turing machine with two read/write heads is more powerful than one with only one.
c)  The answer to this question is True.
d)  The answer to this question is False.

6.  The First-Half operator is defined on page 308 of your text.  Is First-Half closed under CFLs?  Justify your answer.

7.  Fill in the blanks  (Thanks to Steve Fisk)

Kermit:  This is ___________ the Frog reporting for Sesame Street News.  Today we interview Professor Biskit who works on cookie research.  Hello Professor Biskit, what have you got there?

Prof:  Accch, I am trying to find out if there is such a thing as an infinitely long cookie.  This machine will produce every sort of cookie possible:  big cookies, little cookies, square cookies, round cookies.  The cookies come out this hole here.

Kermit:  You mean if you get a really long cookie, it will come out of the hole like a sausage?

Prof:  Yaaas, that's right.  Now I will set the machine going, and we can start watching de cookies.

GRRRRRRUNNNNNNNNNCCCHHHHHH     CHUGGAA  CHUGGAA CHUGGA . . .

Prof:  And here comes one . . .

CLUNK

Cookie Monster:  Cooookie!!  Chomp.

Prof:  And another.  This one is square.

CLUNK

Kermit:  Uh, Professor . . .

Prof:  Don't bother me now, I'm watching cookies.

Kermit:  What if there isn't an infinitely long cookie?

Prof:  Then they will come out of this machine forever - there is an infinite number of cookies you know.

Kermit:  And what if the machine starts making an infinitely long cookie?

Prof:  That's obvious you frong, I will have to wait for it to come out.

Kermit:  And how long will that take?

Prof:  _______________

Kermit:  So if there isn't an infinitely long cookie, you have to wait forever, and if there is, you have to wait forever too.  How are you going to find out if there is an infinitely long cookie today?

Prof:  Don't interrupt.  Here comes a triangular one with purple spots.

Cookie Monster:  CRUNCH.  _____________   GULP.

Prof:  My machine!

Kermit:  Well, it looks as if the cookie monster has transcended the question of whether there is an infinitely long cookie by eating the cookie machine.  A good thing, as the computation was _______________.

8.  Simulate The Wizard of Oz using Star Wars (hint:  use Chewbacca for Toto).