Question: A. (3 points) Consider the methods get (index), add(element), and remove(index, from the java.util.List API. For each of these methods, is there ever a situation

 A. (3 points) Consider the methods get (index), add(element), and remove(index,

A. (3 points) Consider the methods get (index), add(element), and remove(index, from the java.util.List API. For each of these methods, is there ever a situation where the method will run faster for an arrayList than for a Linkedlist? Briefly explain. Assume the Linkedlist is implemented a head pointer and no other instance variables (no size!); that is, it is a singly linked list, and that the ArrayList's backing array is large enough to hold the new element (no enlarge needed). Also assume each of the following operations takes the same amount of time: array lookups, setting elements of arrays, creating new Nodes, traversing a single link in a linked list, and assigning a reference (ex, calling setNext on a node). B. (2 points) Write a public static List 1) method that returns a new list, consisting of the elements of 1 separated by sep. Assume both arguments are non-null. Example 1: Inputs: sepi "a" Returns: {"b", Example 2: Inputs: Page 1 of 2 1/17/21, 1:10 PM sep: "X" 1: {"r") Returns: {"r"}

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!