21
$\begingroup$

It is well-known that palindromes can be recognized in linear time on $2$-tape Turing machines, but not on single-tape Turing machines (in which case the time needed is quadratic). The linear-time algorithm uses a copy of the input, and thus also uses a linear space.

Can we recognize palindromes in linear time of a multitape Turing machine, using only a logarithmic space? More generally, what kind of space-time trade-off is known for palindromes?

$\endgroup$

3 Answers 3

22
$\begingroup$

Using crossing sequences or communication complexity it is simple to derive the tradeoff $T(n)S(n) = \Omega(n^2)$ for a sequential Turing machine using time $O(T(n))$ and space $O(S(n))$.

This result was first obtained by Alan Cobham using crossing sequences in the paper The recognition problem for the set of perfect squares which appeared at SWAT (later FOCS) 1966.

$\endgroup$
25
$\begingroup$

You can use the same argument used to prove the $\Omega(n^2)$ time bound on single tape.

Suppose that you have a TM with $S(n)$ space that recognize palindromes $\{x\,0^{\frac{n}{3}} x^R \mid |x|=n/3 \}$ (where $x^R$ is the reverse of $x$) in time $T(n)$. When the (input) head crosses the middle $0^{n/3}$ it can carry only $S(n)$ bits of information. So it needs to make $\Omega(n / S(n))$ crosses, and each cross requires $n/3$ time.

So $T(n)S(n)=\Omega(n^2)$.

$\endgroup$
4
  • $\begingroup$ Ops... after writing the answer I saw that Kristoffer already posted the solution. Accepts his answer, I leave mine only because it has a few more details. $\endgroup$ Commented Mar 3, 2014 at 13:51
  • 5
    $\begingroup$ I guess it was practically simultaneous. $\endgroup$ Commented Mar 3, 2014 at 14:09
  • $\begingroup$ As you suggested, I accepted Kristoffer's answer since he was a bit earlier... Thanks to both of you! $\endgroup$
    – Bruno
    Commented Mar 3, 2014 at 14:30
  • 1
    $\begingroup$ $\{x0^{\frac{n}{3}} x^R \mid |x|=|y|=n/3 \}$ looks strange. Better $\{x0^{\frac{n}{3}} x^R \mid |x|=n/3 \}$ an annotation that ${}^R$ is the string reverse operator. $\endgroup$
    – miracle173
    Commented Jan 16, 2017 at 11:11
3
$\begingroup$

In addition to the other answers, it's worth noting that if randomization is allowed, palindromes can be recognized with O(1) space and O(n) time by hashing the left side of the string, hashing the transpose of the right side of the string, and checking if the hashes are equal. It shouldn't be hard to do this on a Turing machine.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.