The ________________ operation is required by the Iterable interface.

An application can indicate a specific way to order the elements of a SortedABList list by passing a(n) _________________________ object to a constructor of the list class.

Suppose a list names contains 8 elements. A call to names.add(0, "Albert") results in:

a. an exception being thrown.
b. an 8-element list with "Albert" as the first element.
c. a 9-element list with "Albert" as the first element.
d. a single-element list containing "Albert".
e. None of these is correct.

Answer each of these items in the grid below. Answer must be in one of these exact forms for auto-grade to work: O(1), O(N), O(N^2), O(2^N), O(LOG2N)

a. is the order of growth execution time of the index-based add operation when using the ABList class, assuming a list size of N.
b. is the order of growth execution time of the index-based set operation when using the ABList class, assuming a list size of N.
c. is the order of growth execution time of the indexOf operation when using the ABList class, assuming a list size of N.
d. is the order of growth execution time of the indexOf operation when using the LBList class, assuming a list size of N.

Respuesta :

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)

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.

RELAXING NOICE
Relax