Question
( Java ) Help find the problem of the code, I couldn't get the reverse list right in my test Here is the code: private
( Java ) Help find the problem of the code, I couldn't get the reverse list right in my test
Here is the code:
private BasicLinkedList
if (curr.next == null) {
head = curr;
/* Update next to prev node */
curr.next = prev;
return null;
}
/* Save curr.next node for recursive call */
Node next1 = curr.next;
/* and update next ..*/
curr.next = prev;
return new BasicLinkedList
}
public BasicLinkedList
return ReverseListAuxiliary(head, null);
}
}
Here is the test code:
@Test
public void basicLinkedLIstReverse() {
BasicLinkedList
list1.addToEnd("Hello").addToEnd("World").addToEnd("Mike");
list1.getReverseList();
assertEquals("Mike", list1.getFirst());
assertEquals("Hello", list1.getLast());
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started