Question: public class LinkedList { private Node head; public LinkedList() { head = null; } public void addFront(int newData) { Node newNode = new Node(newData); newNode.next

 public class LinkedList { private Node head; public LinkedList() { head

public class LinkedList { private Node head; public LinkedList() { head = null; } public void addFront(int newData) { Node newNode = new Node(newData); newNode.next = head; head = newNode; } public void addEnd(int newData) { Node newNode = new Node(newData); if(head == null) head = newNode; else { Node curNode = head; while(curNode.next!= null) { curNode = curNode.next; } curNode.next = newNode; } } public void addAfter(int newData, int position) { Node newNode = new Node(newData); //validate the position --TODO //move the curNode to that position int cnt = 0; Node curNode = head; while(cnt"); curNode = curNode.next; } System.out.println(); } private class Node { int data; Node next; Node(int d) { data = d; next=null; } // Constructor } public static void main(String[] args) { LinkedList list = new LinkedList(); for(int i = 1; i  For this project, you will add the following methods to the singly linked list class, see the attached LinkedList.java. xemeeAt(int position) removes the node at the specified position, returning the data of the removed node. It throws an TllegalArgument exception if position is invalid xemozealli) -removes all nodes in the list getNumberOENodes ) - returns the number of nodes in the list squalsa(SinglyLinkedList list) -compares if two lists contain the same nodes in the same order exersereturns a reversed singly linked list. 1. 2. 3. Implement all the above methods with appropriate Javadoc style comments For each method, be sure to test your work by adding test code to a main method in a test class. Add appropriate Javadoc style comments to the rest of the methods in the LinkedList class

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 Databases Questions!