Professional Documents
Culture Documents
Colin Campbell
Engineering Mathematics Department
C.Campbell@bris.ac.uk
Let’s consider the input 1101, the TM will halt with the tape
containing 0010.
Let’s use the notation in the following table with [. . .] indicating
the position of the R/W head. Then the tape content and state is
as follows:
[1] 1 0 1 B q0
0 [1] 0 1 B q0
0 0 [0] 1 B q0
0 0 1 [1] B q0
0 0 1 0 [B ] q0
0 0 1 [0] B q1
From which we deduce that for an input with n binary digits, the
Turing Machine terminates after (n + 1) transitions (one row to
next row counts as +1 so 6 − 1 = 5).
Implementation 1
By scan we mean read, by crossing off we mean write a blank,
more terminology for how these things are written!
1. Scan to end of tape, reject if 0 is found to the right
of a 1.
2. Repeat stage 3 while both 0’s and 1’s remain on the
tape:
3. Move to start of tape; move right crossing off single
0 and 1.
4. Move to start of tape; scan for 0 or 1 (reject) or
reach end (accept).
Implementation 2
However, let’s try this alternative (we omit “move to start of tape”
since this is O (n )):
1. Scan to end of tape, reject if 0 is found to the right of a 1.
2. Repeat stages 3 and 4 while both 0s and 1s remain on the
tape.
3. Scan tape, check whether total number of 0s and 1s is odd.
Reject if odd.
4. Cross off the first 0 and every second 0 after that; repeat for
1s
5. If no 0s or 1s remain on the tape, accept, otherwise reject.
For a 4 × 4 game: