Question: Complete the 4 list methods for the code below. Below that is an example of another method in the same code and the 4 should

Complete the 4 list methods for the code below. Below that is an example of another method in the same code and the 4 should look similar to that.
_________________________________
public E get(int index);
public int indexOf(E e);
public int lastIndexOf(E e);
public E set(int index, E e);
________________________________
public E removeLast(){
if (tail == null){
return null;
}
if (head == tail){
E temp = head.data;
head = tail = null;
size =0;
return temp;
}
Node prev = head;
while (prev.next != tail){
prev = prev.next;
}
E temp = tail.data;
tail = prev;
tail.next = null;
size--;
return temp;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!