Re:The Tortoise and The Hare: Loops in Linked Lists
by gsg on Saturday December 21, 2013 @01:27PM
(#6947431)
Cyclic lists might not be a good interview question, but working through some of the details is a great exercise.
A good follow on from finding whether there is a cycle is finding the length of the lead-in and cyclic parts of the list, and then implementing a map function over cyclic lists. There are some interesting tricks that rely on non-obvious properties of cyclic lists.
A good follow on from finding whether there is a cycle is finding the length of the lead-in and cyclic parts of the list, and then implementing a map function over cyclic lists. There are some interesting tricks that rely on non-obvious properties of cyclic lists.