Find cycle in linked list.
Anonimo
State that you have 2 or more nodes in the list before you begin. Have two pointers P1 & P2. Have pointer P1 point to node #1 and P2 to node #2. Move the pointers : such that, for every node move of P1, P2 moves 2 nodes. (Eg): P1 = P1 -> link P2 = P2 -> link -> link If at any point if P1 and P2 point to the same node, then it means that the list is in a loop. Try this with a few connected nodes in a properly formed linked list to prove to yourself.