Extra Exercise for Chapter 23
23.1 (A Sorting Question for Obama) When presidential candidate Barack Obama visited Google in
2007, Google CEO Eric Schmidt asked Obama the most efficient way to sort a million 32–bit
integers (www.youtube.com/watch?v=k4RRi_ntQc8). Obama answered that the bubble sort would be
the wrong way to go. Was he right? Verify it and find an efficient algorithm for sorting a million
32–bit positive integers using selection sort, insertion sort, bubble sort, merge sort, quick sort, heap
Extra Exercise for Chapter 24
**24.1 (Reverse list) Implement the following two methods in O(n) time.
// Reverse the list and return it in O(n) time
public static <E> ArrayList<E> reverse(ArrayList<E> list)
// Reverse the list and return it in O(n) time
public static <E> LinkedList<E> reverse(LinkedList<E> list)
Use the following code to test these methods:
public static void main(String[] args) {