public abstract class FastQuickSort
extends java.lang.Object
Constructor and Description |
---|
FastQuickSort() |
Modifier and Type | Method and Description |
---|---|
private static <T extends java.lang.Comparable<? super T>> |
insertionSort(T[] array,
java.util.Comparator<T> c,
int l,
int r)
Insertion sort, it is used internally by the quicksort algorithm to sort
the small partitions of values as insertion sort is faster when there is a
relatively small amount of values to sort
NOTE: Through repeated empirical testing of large random data sets using
insertion sort for small sorting operations improved performance by ~10%
|
private static <T extends java.lang.Comparable<? super T>> |
insertionSort(T[] array,
int l,
int r)
Insertion sort, it is used internally by the quicksort algorithm to sort
the small partitions of values as insertion sort is faster when there is a
relatively small amount of values to sort
NOTE: Through repeated empirical testing of large random data sets using
insertion sort for small sorting operations improved performance by ~10%
|
private static <T extends java.lang.Comparable<? super T>> |
quickSort(T[] array,
java.util.Comparator<T> c,
int l,
int r)
An optimized implementation of the quickSort which uses the median-of-three
method for selecting the pivot value to avoid the N^2 worst-case scenario.
|
private static <T extends java.lang.Comparable<? super T>> |
quickSort(T[] array,
int l,
int r)
An optimized implementation of the quickSort which uses the median-of-three
method for selecting the pivot value to avoid the N^2 worst-case scenario.
|
static <T extends java.lang.Comparable<? super T>> |
sort(T[] array)
An optimized implementation of the quickSort which uses the median-of-three
method for selecting the pivot value to avoid the N^2 worst-case scenario.
|
static <T extends java.lang.Comparable<? super T>> |
sort(T[] array,
java.util.Comparator<T> c)
An optimized implementation of the quickSort which uses the median-of-three
method for selecting the pivot value to avoid the N^2 worst-case scenario.
|
private static <T extends java.lang.Comparable<? super T>> |
swap(T[] array,
int i,
int j)
Swaps the values in the array at the indexes provided
|
public static <T extends java.lang.Comparable<? super T>> void sort(T[] array) throws java.lang.Exception
array
- The array to sort, must be objects that implement Comparablejava.lang.Exception
http://en.wikipedia.org/wiki/Quicksort
,
http://stackoverflow.com/questions/2071929/generics-and-sorting-in-java
public static <T extends java.lang.Comparable<? super T>> void sort(T[] array, java.util.Comparator<T> c) throws java.lang.Exception, java.lang.IllegalArgumentException
array
- The array to sort, must be objects that implement Comparablec
- The comparator to use for performing comparisons on the objectjava.lang.IllegalArgumentException
- If the comparison object does not implement Comparatorjava.lang.Exception
http://en.wikipedia.org/wiki/Quicksort
,
http://stackoverflow.com/questions/2071929/generics-and-sorting-in-java
private static <T extends java.lang.Comparable<? super T>> void quickSort(T[] array, int l, int r) throws java.lang.Exception
array
- The array to sort, must be objects that implement Comparablel
- The left boundary of arrayr
- The right boundary of arrayjava.lang.Exception
http://en.wikipedia.org/wiki/Quicksort
,
http://stackoverflow.com/questions/2071929/generics-and-sorting-in-java
private static <T extends java.lang.Comparable<? super T>> void quickSort(T[] array, java.util.Comparator<T> c, int l, int r) throws java.lang.Exception
array
- The array to sort, must be objects that implement Comparablec
- The comparator to use for performing comparisons on the objectl
- The left boundary of arrayr
- The right boundary of arrayjava.lang.Exception
http://en.wikipedia.org/wiki/Quicksort
,
http://stackoverflow.com/questions/2071929/generics-and-sorting-in-java
private static <T extends java.lang.Comparable<? super T>> void swap(T[] array, int i, int j)
array
- The array, must be objects that implement Comparablei
- Index of the value to be swappedj
- Index of the value to be swappedprivate static <T extends java.lang.Comparable<? super T>> void insertionSort(T[] array, int l, int r) throws java.lang.Exception
array
- The array to sort, must be objects that implement Comparablel
- The left boundary of arrayr
- The right boundary of arrayjava.lang.Exception
private static <T extends java.lang.Comparable<? super T>> void insertionSort(T[] array, java.util.Comparator<T> c, int l, int r) throws java.lang.Exception
array
- The array to sort, must be objects that implement Comparablec
- The comparator to use for performing comparisons on the objectl
- The left boundary of arrayr
- The right boundary of arrayjava.lang.Exception