2
I’m having trouble implementing a recursive method for inserting an element at the end of a simply chained list.
Below is the Iterative method:
public void addLast(Node<E> novoNodo){
if(isEmpty())
addFirst(novoNodo);
else{
novoNodo.setNext(null);
tail.setNext(novoNodo);
tail = novoNodo;
size++;
}
}
In the exercise I’m trying to accomplish, I need to turn this method into recursive, but I don’t know how I can accomplish this, since the method last
is not a method with ties.
It’s strange even that your
addLast
have no ties. Are sure that your implementation is correct? :)– hugomg