Question: You will need this code in order to complete the project. Part A: In each of the three types of lists, I left out the
You will need this code in order to complete the project.
Part A: In each of the three types of lists, I left out the code for the add method. Insert code to complete the method. As we discussed in class,
in a singly-linked list, start at the head and iterate to the proper index before inserting a new node.
in a doubly-linked list, start at either the head or tail (whichever is closer) and iterate to the proper index before inserting a new node.
in an array list with size less than the array's capacity, shift elements in higher indices before inserting the new value.
in an array list at capacity, create a new array with twice the capacity and copy each element from the old array into its new index.
Remember to ensure that the methods you write work in all corner cases: list size 0, index 0, and index equal to list size. Test your code before moving on to part B.
Part B: Run the ListTimer class to gather data on the runtime of adding an element to the front of singly-linked lists of various sizes. Modify the code to gather similar data for doubly-linked lists and array lists. Import your data into a spreadsheet program and create a line graph plotting the three sets of runtimes against one another (you should remove any absurd outliers so your graphs are readable). Then repeat the process for adding an element to the end and for adding an elemnt to a random valid index in the list. Once you have completed all three graphs, write a short analysis on whether or not the data matches the theory for each graph.
I need code in Java language.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
