In the best method to detect a cycle in a linked list, we do the following:
- Use Floyd's Cycle-Finding Algorithm and identify a position within the cycle in a linked list.
- Count the size of the cycle in the linked list
- Position one pointer at the beginning of the list and another 'k' (where k is the size of the cycle) positions away.
- On iteration they meet at the beginning of the cycle.
I'd like to know why this works. Some theoretical logic behind this?