edu.stanford.math.plex4.utility
public static class Quicksort.GenericArray<T> extends java.lang.Object
| Constructor and Description |
|---|
Quicksort.GenericArray() |
| Modifier and Type | Method and Description |
|---|---|
static <T> int |
partition(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
The fundamental partition operation for quicksort.
|
static <T> void |
quicksort(T[] array,
java.util.Comparator<T> comparator)
Performs the quicksort algorithm in place on the supplied array.
|
static <T> void |
quicksort(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
Performs the quicksort algorithm in place on a subarray of the
supplied array.
|
static <T> int |
randomizedPartition(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
This function performs the same function as the partition function, except that
it uses a randomly chosen pivot.
|
static <T> void |
randomizedQuicksort(T[] array,
java.util.Comparator<T> comparator)
This performs the randomized quicksort algorithm in place on the
supplied array.
|
static <T> void |
randomizedQuicksort(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
This performs the randomized quicksort algorithm in place on a subarray of the
supplied array.
|
static <T> T |
randomizedSelect(T[] array,
int i,
java.util.Comparator<T> comparator)
This function returns the i-th order statistic of the data in the supplied array.
|
static <T> T |
randomizedSelect(T[] array,
int startIndex,
int endIndex,
int i,
java.util.Comparator<T> comparator)
This function performs the randomizedSelect on a subarray of the supplied array.
|
public static <T> void quicksort(T[] array,
java.util.Comparator<T> comparator)
array - the array to sortpublic static <T> void quicksort(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
array - the array to sortstartIndex - the first index of the subarrayendIndex - the last index of the subarraypublic static <T> void randomizedQuicksort(T[] array,
java.util.Comparator<T> comparator)
array - public static <T> void randomizedQuicksort(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
array - the array to sortstartIndex - the first index of the subarrayendIndex - the last index of the subarraypublic static <T> int partition(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
array - the array to arrangestartIndex - the first index of the subarrayendIndex - the last index of the subarraypublic static <T> int randomizedPartition(T[] array,
int startIndex,
int endIndex,
java.util.Comparator<T> comparator)
array - the array to arrangestartIndex - the first index of the subarrayendIndex - the last index of the subarraypublic static <T> T randomizedSelect(T[] array,
int i,
java.util.Comparator<T> comparator)
array - the array to searchi - the rank of the order statistic to findpublic static <T> T randomizedSelect(T[] array,
int startIndex,
int endIndex,
int i,
java.util.Comparator<T> comparator)
array[startIndex, ..., endIndex].array - the array to searchstartIndex - the first index of the subarrayendIndex - the last index of the subarrayi - he rank of the order statistic to find