I have currently have 2 classes, Images and ImageNode. Inside the ImageNode class I have a recursive method that reverses the linked list. I believe my code is correct for that method, however i'm confused as to how I should be calling this method inside my Images class.
ImageNode method ---
public ImageNode reverseUsingPrevious(ImageNode previous) {
if(previous == null) return previous;
ImageNode next = previous.getNext();
if(next == null) return previous;
previous.setNext(null);
ImageNode rev = reverseUsingPrevious(next);
next.setNext(previous);
return rev;
}
Images method ----
private void reverseRec() {
cursor.reverseUsingPrevious(head);
//the cursor is the currently selected image(node), head is the start of the linked list
}
I'm not 100% sure what I should be parsing into reverseUsingPrevious method.