|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--DataStructures.Sort
A class that contains several sorting routines, implemented as static methods. Arrays are rearranged with smallest item first, using compareTo.
Constructor Summary | |
Sort()
|
Method Summary | |
static void |
heapsort(Comparable[] a)
Standard heapsort. |
static void |
insertionSort(Comparable[] a)
Simple insertion sort. |
static void |
main(java.lang.String[] args)
|
static void |
mergeSort(Comparable[] a)
Mergesort algorithm. |
static void |
quickSelect(Comparable[] a,
int k)
Quick selection algorithm. |
static void |
quicksort(Comparable[] a)
Quicksort algorithm. |
static void |
shellsort(Comparable[] a)
Shellsort, using Shell's (poor) increments. |
static void |
swapReferences(java.lang.Object[] a,
int index1,
int index2)
Method to swap to elements in an array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Sort()
Method Detail |
public static void insertionSort(Comparable[] a)
a
- an array of Comparable items.public static void shellsort(Comparable[] a)
a
- an array of Comparable items.public static void heapsort(Comparable[] a)
a
- an array of Comparable items.public static void mergeSort(Comparable[] a)
a
- an array of Comparable items.public static void quicksort(Comparable[] a)
a
- an array of Comparable items.public static final void swapReferences(java.lang.Object[] a, int index1, int index2)
a
- an array of objects.index1
- the index of the first object.index2
- the index of the second object.public static void quickSelect(Comparable[] a, int k)
a
- an array of Comparable items.k
- the desired rank (1 is minimum) in the entire array.public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |