c++ - When will Floyd's cycle-finding algorithm fail? -


i interview question floyd's cycle-finding algorithm :

when floyd's cycle-finding algorithm fail ?

i mean, there rule finding step between fast , slow pointers ?

under reasonable assumptions, won't fail. either find cycle or conclude there isn't one.

the failure scenarios can think of along following lines:

  • there's bug in implementation;
  • the structure that's being traversed gets modified while algorithm in progress.

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -