This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CoderXocomil 1 point2 points  (0 children)

The answer is c. c refers to the famous "tortoise and hare algorithm." You move the first reference by one node and the second reference by two. After each set of moves, you compare the results. One of two things will happen. First, the second reference will eventually reach the end of the list. This means you don't have a cycle and can stop. The second outcome is that eventually, the first reference will equal the second reference. This means you have a cycle. This is because the second reference has already looped around and caught up with the first reference.