Tuesday, November 9, 2004
Implement the Quick-Sort algorithm for sorting an array of integers. You can start with the book's description of the in-place algorithm in Code Fragments 10.6 and 10.7. But the book uses a generic Object array and Comparator objects for its code: you are to just write a Java method that uses an primitive integer (int) array and the usual < operator.
Also, the book's algorithm only works if all the elements in the array are distinct. You should figure out what happens with the book's algorithm if there are duplicate elements in the array, and improve the algorithm. (See Exercises R-10.11 and R-10.8 on pages 533 and 534.)
Hand in a printout of all the commented Java program files that are necessary to make your program run correctly, and also submit them online through VikingWeb.