Tuesday, September 11, 2007

Detecting Cycle in Link List

This problem has become a standard and cliched question among candidates seeking computer programming jobs. The most common solution is to have two pointers and have them traverse the list at different speeds (normally 1:2) - eventually they will meet if there is a cycle. I had thought about another solution which I sent to a web site which hosts all known solutions to this problem. This website has published my solution and it is available here -

http://ostermiller.org/find_loop_singly_linked_list.html

Search for my name in this link - the solution has been credited to me :-).