Answer:
For question one, the first line It is Iteration, The second line is Comparator, the third line is none of these is correct.
Question two, the index based method for (a) is O(1) (b) O(1) (c) O(N) (d) O(N)
Step-by-step explanation:
Solution to the question
Question 1:
The Iteration operation is required by the Iterable interface.
n application can indicate a specific way to order the elements of a SortedABList list by passing a(n) Comparator so that we can customize the sorting object to a constructor of the list class.
Suppose a list names contains 8 elements. A call to names.add(0, "Albert") results in: (e) None of these is correct
Question 2:
let us assume that the LBList is built on top of a Linked List and the ABList is built on top of an array:
(a) the add method index based is O(1) in the average case and the O(N) in the worst case
(b) The Index based set operation is O(1) since we can simply move to any index of an array of time constant.
(c) It is O(N) since index Of method needs to look for the whole array (based on worst case or average) to get the index
(d) It is O(N) since index Of method needs to find the whole linked list (on worst case or average ) to search the index.