Questions tagged «linked-lists»

3
弗洛伊德循环检测算法| 确定周期的起点
我正在寻求帮助来了解弗洛伊德的循环检测算法。我已经对Wikipedia(http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare)进行了解释。 我可以看到算法如何检测O(n)时间的周期。但是,我无法想象这样一个事实,即一旦乌龟和野兔指针第一次相遇,就可以通过将乌龟指针移回起点,然后一次移动乌龟和野兔一步来确定周期的开始。他们初次见面的时间就是周期的开始。 有人可以提供一种解释,希望与维基百科上的解释有所帮助,因为我无法理解/可视化它?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.