Floyd's tortoise & hare
a pointer algorithm that uses only two pointers, which move through the sequence at different speeds. - Cycle detection
- find if cycle exists
- find position of first repetition
- find cycle length
see also
- rosettacode.org
-
Brent’s algorithm use a faster model with progressive speed.
- If Programming Was An Anime
- Possibly all the ways to get loop-finding in graphs wrong / HN
Written on April 9, 2021, Last update on September 16, 2024
graph
cycle
algorithm