Question: For this project, you must implement a set of methods that perform basic operations on a linked list of integers. Each method performs a different

For this project, you must implement a set of methods that perform basic operations on a linked list of integers. Each method performs a different basic operation as described below. All of the below methods must be public and static and implemented in the Main class (not in the Node class).
Note that each of these methods takes as an argument a reference to the head Node of a linked list to operate on. Also note that any method which alters the contents of the list will also return a reference to the head Node of the list - this is because operating on a list may cause the list to have a new head Node. For example, adding to the front of a linked list will result in the list having a new Node as its head Node.addAtFront(Node, int) : Node When called and passed a reference to the head Node of a linked list and an int value to add to the list, this method will create a new Node object to store the int value, and will then make this Node the new head Node for this linked list. This method must return a reference to the new head Node.
printList(Node) When called and passed a reference to the head Node of a linked list, this method will print out a comma separated list of the int values in the linked list. This method will not return anything.
The printed output must be formatted like the following examples:
{}
{55}
{11,22,33}
getSize(Node) : int When called and passed a reference to the head Node of a linked list, this method must compute and return the number of nodes in the list.
addToEnd(Node, int) : Node When called and passed a reference to the head Node of a linked list and an int value to add to the list, this method will create a new Node object to store the int value, and then will make this Node the new last Node in this linked list.
This method must return a reference to the head Node of the list.
removeFromFront(Node) : Node When called passed a reference to the head Node of the linked list, this method will remove the current head node of the list and return a reference to the new head Node.
removeFromEnd(Node) : Node When called and passed a reference to the head Node of a linked list, this method will remove the last Node of the list and return a reference to the head Node.
insertAtIndex(Node, int, int) : Node The first argument will be the head of a linked list.
The second argument will be the zero-based index where the new value should be inserted.
The third argument will be the new value to be inserted into the list.
When called and passed a reference to the head Node of a linked list, an index, and a new int value, this method must make a new Node to store the new int value, and insert the node at the correct index in the list.
This method must return a reference to the head Node of the list.
removeAtIndex(Node, int) : Node The first argument will be the head of a linked list.
The second argument will be the zero-based index of the Node that should be removed.
When called and passed a reference to the head Node of a linked list, and an index, this method must remove the specified Node from the list.
This method must return a reference to the head Node of the list.

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!