在研究找环算法时,我经常遇到这些表达式,但我不确定它们只是同义词还是有区别。
不完全是。
Two pointers algorithm
是相当广泛的方法,适用于解决许多问题。
Hare & tortoise algorithm
和 fast & slow algorithm
可能被视为同一方法的不同名称 - 并且此方法是上述 Two pointers
方法的子类。
Floyd 的循环查找算法使用
fast & slow
方法,但还有另一种 Brent 的循环检测算法 也使用 fast & slow
。
所以有一种层次结构 -
Two pointers -> fast & slow -> Floyd's cycle-finding