0
/ 10
Using this class definition:
public class node<E> { //... instance variables public node(E d, node<E> n) { this.data = d;...
Using this class definition:
public class node<E> {
//... instance variables
public node(E d, node<E> n) {
this.data = d;
this.next = n;
}
public E getData() {return data; }
public void setData(E d) {data = d; }
public node<E> getNext() {return next; }
public void setNext(node<E> n) {next = n; }
}
Assume we have built a linked list with four nodes as shown in the image below and we pass this node (the pointer to the first element, head) to the routine below.
Complete the method changeMe
to modify the list
passed in as argument in variable head
and return
a pointer to a list as shown below:
Your feedback will appear here when you check your answer.