|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectQuicksort
public class Quicksort
The Quicksort Java application illustrates a quicksort.
Part of the implementation (the partition method) is left
as a student exercise.
partition:
| Constructor Summary | |
|---|---|
Quicksort()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
The main method illustrates the use of a quicksort to sort a small array. |
static void |
quicksort(int[] data,
int first,
int n)
This method cannot be used until the student implements partition. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Quicksort()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
String arguments (args) are not used
in this implementation.
public static void quicksort(int[] data,
int first,
int n)
partition.
Sort an array of integers from smallest to largest, using a quicksort
algorithm.
data - the array to be sortedfirst - the start index for the portion of the array that will be sortedn - the number of elements to sort
data[first] through data[first+n-1] are valid
parts of the array.
n is zero or negative then no work is done. Otherwise,
the elements of data have been rearranged so that
data[first] <= data[first+1] <= ... <= data[first+n-1].
java.lang.ArrayIndexOutOfBoundsException - Indicates that first+n-1 is an index beyond the end of the
array.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||