I need to write a method that inserts items into a singly linked sorted list recursively. The node class for the list looks like this:
protected class Node<T> {
protected Node(T data) {
this.data = data;
}
protected T data;
protected Node<T> next;
}
protected Node<E> head;
}
The method signature is: void insert(E data). I can do this iteratively but I just can't seem to wrap my head around how to do it recursively. Can anyone offer any insight?