2 ms·
I don't understand... why does the turtle need to move at all?
by rflrob 17y ago
I don't understand... why does the turtle need to move at all?
- Batsu 17y agoIf you have the tortoise and hare start at 1, but there is a loop going 2 -> 3 -> 2 -> ... then, without moving the tortoise, the hare will never find the tortoise or the end of the list.
- mbrubeck 17y agoThe cycle might not include the head of the list. You need to keep moving the turtle until it is in the cycle. Otherwise the rabbit will enter the circle and keep running around and never see the turtle again. Crude ASCII art version: TURTLE-->--+--->--+ / \ | RABBIT \ / +---<--+