I am reading an example in Sipser's famous book on the theory of computation. In this example, Sipser creates a turing machine M to solve the element distinctness problem. M is given a list of strings over $\Sigma = \{0, 1\}$ separated by #s. M must only accept if all the separated strings are different.
The book lists the following high-level implementation of such a machine.
- Place a mark on the top of the leftmost tape symbol. If that symbol was blank (_), accept. If that symbol was a #, then continue with the next stage. Otherwise, reject.
- Scan right to the next # and then place a mark over it. If no # is encountered before a blank symbol, accept since only one string is listed.
- By zig-zagging, compare the 2 strings to the right of the marked #s. Reject if they are equal.
- Move the rightmost of the two marks to the next # to the right. If no # symbol is encountered before a blank symbol, move the leftmost mark to the next # to its right and the rightmost mark to the # after that. This time, if no # is available for the rightmost mark, all the strings have been compared, so accept.
I am not sure how to picture this implementation. Why are we putting marks above #? Aren't we just comparing strings? Also, what is "zig-zagging"?