|
|
|
|
|
by bombastry
1652 days ago
|
|
If you check every node that the hare enters, you don't need the relative speed to be coprime to the cycle-length. This eliminates the need for the hare and tortoise to finish a round on the same node; the hare passing the tortoise is sufficient evidence to detect a cycle. This change adds a performance penalty with the extra equality checks, but can reduce the total number of steps in certain contexts (e.g. lists with long cycles that appear at an early node can benefit from a much faster hare). |
|
> This change adds a performance penalty with the extra equality checks, but can reduce the total number of steps in certain contexts
The post seems to think that most of the value in this approach comes from the fact that it's easy to identify the beginning of the cycle after you've identified that the cycle exists. The method relies on the tortoise and hare finishing a round on the same node. Does that generalize to the case where the hare just passes the tortoise at some point?