public static SNode reverseIte(SNode curr) {
SNode prev = null;
SNode next = null;
while(curr != null) {
next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
return prev;
}
public static SNode reverseLinkedList(SNode curr) {
if(curr == null || curr.next == null)
return curr;
SNode head = reverseLinkedList(curr.next);
curr.next.next = curr;
curr.next = null;
return head;
}
public static SNode reversePair(SNode head) {
SNode curr = head;
while(curr != null && curr.next != null) {
int tmp = curr.data;
curr.data = curr.next.data;
curr.next.data = tmp;
curr = curr.next.next;
}
return head;
}
public static boolean isCircular(SNode curr) {
if(curr == null)
return false;
else {
SNode next = curr.next;
if(curr == next)
return true;
while(next != null) {
if(curr == next)
return true;
curr = curr.next;
next = next.next;
if(next != null)
next = next.next;
}
}
return false;
}