4

I'm trying to figure out the time-complexity of a turing machine that accepts repeat strings (ww) in three cases: a 1-tape deterministic machine, a 2-tape deterministic machine, and 1-tape nondeterministic machine.

Right now my thoughts are that

  • the 1-tape deterministic machine takes O(n^2) to find the midpoint (by crossing out the first and last symbols in the input repeatedly) and O(n^2) to compare the first and seconds halves (as it has to go back and forth n/2 times, each time going through n/2 of the string),

  • the 2-tape TM take O(n^2) to find the midpoint, O(n) to copy the second half to the second tape, then O(n) to compare the two halves simultaneously,

  • and the nondeterministic one guesses the midpoint and take O(n^2) to compare the two halves.

However, I feel like the three cases should not all have the same time complexity of O(n^2) so was wondering if my reasoning is incorrect somewhere (or whether I am correct and just thinking to much about the problem). Any input would be appreciated!

Déjà vu
  • 28,223
  • 6
  • 72
  • 100
scaevity
  • 3,991
  • 13
  • 39
  • 54

1 Answers1

0

In using magnetic tapes, this logic seems correct. On a magnetic disk or solid state drive, different algorithms better suited to accessing data non-linearly would have lower big-Os.

So you are correct on all of them. They are all O(n^2). It is one reason that tape has gone the way of the dinosaurs for active work. For backup, they are still used in some places, but that is because they are still only O(n) for linear storage.

AlexG
  • 31
  • 6