Question: interface List E{ void addFront (E); //Add Element at the beginning of the list void addEnd (E);// Add Element at the end of the list



interface List E\{ void addFront (E); //Add Element at the beginning of the list void addEnd (E);// Add Element at the end of the list void addMid (E val , EX);// Add Element after the value val in the list void print ();// print all the elements in the list boolean empty ();// return true if the list is empty void removeEnd();// remove the last element in the list void removeFront ();// remove the first element in the list void remove(E x);// remove the element x from the list void removeAll();// remove all elements in the list boolean exist(E x);// check if the element x is in the list \} Linked List implementation 1. Defining class Node A list contain a head which is a pointer (reference) to the first node. The first step we should define a Node Class Node\{ E data; Node next; public Node(E data)\{ this.data = data; next = nul1; \} return datat " "; public String tostring()\{ retur - Printing all element in the list public void print() \{ // TODO 2/9 Lab3 - Student.md - Check if the list is empty or not You have to check if the list is not empty! You have to check if the list contains only one element! public void removeEnd() \{ //TODO } - Remove the first element in the list You have to check if the list is not empty! P The pointer should be the predecessor of the node to remove! public void remove(E X) \{ //TODO - Remove all elements in the list public void removeAll() \{ //TODO \} - Search an element in the list public boolean exist (Ex) f 1/1TOOO
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
