How to prepare for the final

The final will contain both questions on Java programming and some questions that cover new material that we have seen since the second midterm exam. The new material includes Scheme programming, Turing Machines, and Neural Networks.

For the Java programming questions, you should review the sample questions I gave for the second midterm.

Below are some sample questions for the new material.

Sample Questions

1. Draw the state-transition diagram for a Turing machine that turns every other 1 in a sequence of 0s and 1s into a 0. For example, if the tape contains the sequence

011101010111

the machine will halt with the sequence

010100010010

on its tape.

Solution

2. Draw the state-transition diagram for a Turing machine that executes the following program. The machine starts with its head over a 1 on the tape and a sequence of 1s off to the right. It replaces all of the 1s with blanks, and ends up with its tape head over the same cell it started on.

Solution

3. Consider the following Scheme function definition:

(define (mystery x y)
  (if (> x y)
      (mystery (- x y) y)
      x))

Solution

What value does this function return when we call (mystery 20 3)? In general, what does this function do?

4. Write the code for a Scheme function named 'length' that computes the length of a list. For example,

(length (list a b c))

should return 3.

Solution

5. In this course we have seen a variety of different computing paradigms. The standard paradigm is procedural program with if statements, loops, and methods. Some of the non-standard computation schemes we have studied include

How does each of these computation schemes differ from the standard paradigm?