I am trying to implement the boolean method taking a parameter of ListNode list then the method will return true if the list meets null. I think I can do this part, but the problem is for the false statement. If the nodes points back to previous node then it should return false. For example, 2 , 4, 5, null --> true 2 , 4, 5, (points back to previous node) 4, 5, 4, 5, etc
the below code is what i did so far..
public static <T> boolean terminates(ListNode<T> list) {
// TODO: Part of this assignment is to implement this correctly.
if(list == null) {
return true;
}
else {
while(list != null) {
list = list.next;
}
return true;
}
}