3.8 The following routine removes the first half of the list passed as a parameter: public static void removeFirstHalf( List> lst ) { int theSize = lst.size( ) / 2; for( int i = 0; i < theSize; i++ ) lst.remove( 0 ); } 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? | |
| View Solution | |
| << Back | Next >> |