Question: Consider the ArrayList and LinkedList implementations of an indexed List. Suppose that list 1 is an ArrayList object and list 2 is a LinkedList object.

Consider the ArrayList and LinkedList implementations of an indexed List.
Suppose that list1 is an ArrayList object and list2 is a LinkedList object. Both
list 1 and list 2 have n elements.
We want to add an element at index 0, given that each list has n elements.
a) What is the time complexity of list1.add(0, element)? Explain.
b) What is the time complexity of list2. add (0, element)? Explain.
We want to remove the last element at index (n-1.
c) What is the time complexity of list1. remove(n-1)? Explain.
d) What is the time complexity of list2. remove(n-1)? Explain.
We want to get the element at index n2.
e) What is the time complexity of list1.get(n/2)? Explain.
f) What is the time complexity of list2.get(n/2)? Explain.
 Consider the ArrayList and LinkedList implementations of an indexed List. Suppose

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!