Question: Length attribute Add a public integer attribute in the class List called length that keeps track of how many elements we have in the list.

Length attribute
Add a public integer attribute in the classListcalledlengththat keeps track of how many elements we have in the list. Modify all the existing methods in this class to make sure that the length is updated properly. For example, in the functions inserting new elements in the list, you should increment the length, and in those removing an element you should decrease it. Modify the functionprintNodesto add a statement at the beginning telling us how many elements we have in the list based on the length. In all the other methods you implement for the homework, also make sure to update the length properly.
Increment values
Add a method in the classListwith the header (signature)
public void incrementValues()that traverses the list and increments the value of every node by 1. This function should not output anything and should not insert or remove nodes from the list. Add a test case for it in themain.
Search by value
Add a method with the header
public Node searchValue(int val)
to the classList. This method should traverse the list and search the nodes for the value passed in as parameter. If the value is found in the list, the method should return a reference to the node containing it. If the value is not in the list, or if the list is empty, the meth

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!