I want to write a method to recursively reverse a linked list.
I have been working on it for awhile but I haven't been able to get very far on it.
Here is the code I have so far:
public Node recursiveThisList(Node previous, Node current){
if(previous == null)
return null;
if(previous.equals(head)){
previous.setNext(null);
}
if(current == null){
head = previous;
return head;
}else{
Node temp = current.getNext();
current.setNext(previous);
reverseR(current, temp);
}
return null;
Is there a way to do this with a void method and without any parameters: public void recursiveThisList().
Thanks.

New Topic/Question
Reply



MultiQuote





|