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
Post a Comment