Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Algebra advanced algebra with financial applications

Authors: Robert K. Gerver

1st edition

978-1285444857, 128544485X, 978-0357229101, 035722910X, 978-0538449670

More Books

Students also viewed these Programming questions