import adt.LinkedList;
public class Q007_Detect_Loop_In_A_Linked_List {
public static void main(String[] args) {
LinkedList list = new LinkedList();
ListNode node1 = list.append(1);
ListNode node2 = list.append(2);
ListNode node3 = list.append(3);
ListNode node4 = list.append(4);
ListNode node5 = list.append(5);
// make a loop
node5.next = node2;
boolean res = detectLoop(list);