Java. Refer to screenshot. There is starter code for this question. public class LinkedList { Node head; Node tail; protected class Node{ String data; Node next; } public String removeFirst(){...


Java. Refer to screenshot. There is starter code for this question.


public class LinkedList {
Node head;
Node tail;


protected class Node{
String data;
Node next;
}






public String removeFirst(){
//Complete the implementation of removeFirst
}


public String toString(){


String result = "";


Node n = head;
while(n != null){
result += n.data + " -> ";
n = n.next;
}


return result;
}




}


Now, you will implement the remove first method.<br>The method will remove the first element from the list and return the data stored in the node. If the list is empty the method should return null<br>Mimir will use a subclass of linked list with a working version of add last.<br>Example<br>Output<br>Alice -><br>Alice -> Bob -><br>Alice -> Bob -> Eve -><br>Removed: Alice<br>Bob -> Eve -> Jake -><br>Input<br>4 false Alice false Bob false Eve true Jake<br>Removed: null<br>Mike -><br>1 true Mike<br>

Extracted text: Now, you will implement the remove first method. The method will remove the first element from the list and return the data stored in the node. If the list is empty the method should return null Mimir will use a subclass of linked list with a working version of add last. Example Output Alice -> Alice -> Bob -> Alice -> Bob -> Eve -> Removed: Alice Bob -> Eve -> Jake -> Input 4 false Alice false Bob false Eve true Jake Removed: null Mike -> 1 true Mike

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here