The following routine removes the first half of the list passed as a parameter: public static void

Question:

The following routine removes the first half of the list passed as a parameter:
public static void removeFirstHalf( List<?> 1st ) int theSize = 1st.size( ) / 2; for( int i = 0; i < theSize; i++ ) 1st.

a. Why is theSize saved prior to entering the for loop?
b. What is the running time of removeFirstHalf if lst is an ArrayList?
c. What is the running time of removeFirstHalf if lst is a LinkedList?
d. Does using an iterator make removeHalf faster for either type of List?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: