Cycle detection

From Rosetta Code
Revision as of 15:05, 25 February 2016 by rosettacode>Paul.chernoch (Detect the length and starting index of a periodic cycle in a series of numbers)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Detecting cycles in iterated function sequences is a sub-problem in many computer algorithms, such as factoring prime numbers. Some such algorithms are highly space efficient, such as Floyd's cycle-finding algorithm, also called the "tortoise and the hare algorithm". A more efficient algorithm is Brent's Cycle algorithm.

See https://en.wikipedia.org/wiki/Cycle_detection for a discussion of the theory.