Problem solved in full
-
Configurations the palindrome program passes through on 1 0 1 0 1 5 steps
The palindrome program starts on the tape 1 0 1 0 1, head on cell 0, state
q0. Count every configuration it passes through before it halts โ from the rule table, without stepping it โ and then say what that count does as the input gets longer.-
Read the table as rounds, not as a list of moves. Only one rule can open a round:
q0erases the leftmost symbol and branches on what it just erased, toq1for a 1 and toq2for a 0. That branch is the entire comparison mechanism. The machine never stores the symbol on the tape; it stores it in which state it is in, so testing the far end against it later costs no extra moves. -
Count one round on a block of m symbols. Erasing the left end is 1 move. The head then crosses the m โ 1 symbols still standing and spends 1 more move on the blank beyond them to turn around. Erasing the right end is 1 move, walking back over the m โ 2 survivors is m โ 2 moves, and 1 last move on the blank at the left end faces the machine right again in
q0. -
Our tape gives a block of 5, then 3, then a single symbol โ and a single symbol is not a round.
q0erases it,q1walks off the right end and turns, andq1cfinds a blank where a partner should be. An odd-length palindrome has an unmatched centre, and finding that blank is what accepts. -
Add the three, then mind the fencepost. 21 is the number of moves; the transport counts configurations, and 21 moves visit 22 of them once you include the one you started in.
-
Generalise to any odd length n. The blocks run n, n โ 2, and so on down to 3, each costing 2m + 1, with the centre costing 3. Summing that list gives a quadratic in n, not a linear one.
Answer
22 configurations โ 21 moves. The quadratic is the part worth keeping. A 21-symbol palindrome costs 253 moves: 12 times the work for an input 4.2 times as long. The reason is geometric rather than clever โ the two symbols being compared always sit at opposite ends of what is left, and there is one head, so every pair costs one full traverse of the remaining tape. Give the machine a second tape and the same job goes linear: copy the input across as you read it, then run the two heads in opposite directions and compare in one pass, roughly 3n moves. On one tape there is nowhere to put that copy, and the shuttling is forced.
-
References (3)
- The single-tape quadratic lower bound for palindromes: F. C. Hennie, "One-tape, off-line Turing machine computations." Information and Control 8(6), 553โ578, 1965.
- Where multi-tape time complexity classes were set out: J. Hartmanis and R. E. Stearns, "On the computational complexity of algorithms." Transactions of the American Mathematical Society 117, 285โ306, 1965.
- The machine itself: A. M. Turing, "On Computable Numbers, with an Application to the Entscheidungsproblem." Proceedings of the London Mathematical Society s2-42(1), 230โ265, 1937.