Question: Exercise 10.1 Why bother with two different representations of a list? Exercise 10.2 Fill out the missing entries in the following table: Table 10.3

Exercise 10.1 Why bother with two different representations of a list? Exercise10.2 Fill out the missing entries in the following table: Table 10.3ArrayList vs. LinkedList - worst case time complexity comparisons of methods. Method

Exercise 10.1 Why bother with two different representations of a list? Exercise 10.2 Fill out the missing entries in the following table: Table 10.3 ArrayList vs. LinkedList - worst case time complexity comparisons of methods. Method indexOf(E element) add(int index, E element) add(E element) remove(int index) set (int index, E element) get (int index) Iterator.remove() ArrayList LinkedList 0(1) O(n) Exercise 10.3 Given a List of integers and an integer b, write a method that moves all elements in the list that are equal to b to the end of the list and returns the updated list. //moves all occurrences of b to the end of the list, mutating the list List moveToEnd (List list, int b) { /* YOUR CODE HERE "/ return list; // return the modified list Your solution should update the list in place and it doesn't have to maintain the order of the integers in the list. There are several ways to solve this problem. Your solution should require only one pass through the array. You can use either the ArrayList or the ResizingArrayList methods you imple- mented in class. What is the Big- running time of your solution? Some sample input/outputs: Input Output ([2, 1, 2, 2, 2, 6, 8, 2], 2) [1, 6, 8, 2, 2, 2, 2, 2] ([1, 2, 3, 4], 3) ([], 77) ([1, 1, 1, 1, 1], 77) (Each line is a singe input/output pair.) [1, 2, 4, 3] [] [1, 1, 1, 1, 1]

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!