Chapter 12

Section 12.1

1. Consider the general algorithm that repeatedly cancels the same letter from each end of the input string by replacing its occurrences by Λ. A Turing machine program to accomplish this follows, where the start state is 0.

(0, a, Λ, R, 1)

Replace a by Λ.

(0, b, Λ, R, 4)

Replace b by Λ.

(0, Λ, Λ, S, Halt)

It's an even-length palindrome.

(1, a, a, R, 1)

Scan right.

(1, b, b, R, 1)

Scan right.

(1, Λ, Λ, L, 2)

Found the right end.

(2, a, Λ, L, 3)

Replace rightmost a by Λ.

(2, Λ, Λ, S, Halt)

It's an odd-length palindrome.

(3, a, a, L, 3)

Scan left.

(3, b, b, L, 3)

Scan left.

(3, Λ, Λ, R, 0)

Found left end.

(4, a, a, R, 4)

Scan right.

(4, b, b, R, 4)

Scan right.

(4, Λ, Λ, L, 5)

Found ...

Get Discrete Structures, Logic, and Computability, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.