@Test public void shouldReverseLinkedListRecursive() { ListNode<Integer> head = new ListNode<Integer>(1); ListNode<Integer> n2 = new ListNode<Integer>(2); ListNode<Integer> n3 = new ListNode<Integer>(3); ListNode<Integer> n4 = new ListNode<Integer>(4); head.setNext(n2); n2.setNext(n3); n3.setNext(n4); ListNode reversedList = reverseLinkedList.reverseRecursive(head); assertEquals(n4, reversedList); assertEquals(n3, reversedList.getNext()); assertEquals(n2, reversedList.getNext().getNext()); assertEquals(head, reversedList.getNext().getNext().getNext()); }
public ListNode<Integer> reverseRecursive(ListNode list) { validateInput(list); return reverseRecursiveInner(list); }
ReverseLinkedList { public ListNode<Integer> reverseRecursive(ListNode list) { validateInput(list); return reverseRecursiveInner(list); } }
ReverseLinkedList { public ListNode<Integer> reverseRecursive(ListNode list) { validateInput(list); return reverseRecursiveInner(list); }  }
ReverseLinkedList { public ListNode<Integer> reverseRecursive(ListNode list) { validateInput(list); return reverseRecursiveInner(list); }  ListNode reverseIterative(ListNode list); ListNode<Integer> reverseRecursive(ListNode list); }
ReverseLinkedList { public ListNode<Integer> reverseRecursive(ListNode list) { validateInput(list); return reverseRecursiveInner(list); }  ListNode reverseIterative(ListNode list); ListNode<Integer> reverseRecursive(ListNode list);  }