All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class DataStructures.Sort

java.lang.Object
    |
    +----DataStructures.Sort

public final class Sort
extends Object
A class that contains several sorting routines, implemented as static methods. Arrays are rearranged with smallest item first, using compares.


Constructor Index

 o Sort()

Method Index

 o heapsort(Comparable[])
Standard heapsort.
 o insertionSort(Comparable[])
Simple insertion sort.
 o mergeSort(Comparable[])
Mergesort algorithm.
 o quickSelect(Comparable[], int)
Quick selection algorithm.
 o quicksort(Comparable[])
Quicksort algorithm.
 o shellsort(Comparable[])
Shellsort, using a sequence suggested by Gonnet.
 o swapReferences(Object[], int, int)
Method to swap to elements in an array.

Constructors

 o Sort
public Sort()

Methods

 o insertionSort
public static void insertionSort(Comparable[] a)
Simple insertion sort.

Parameters:
a - an array of Comparable items.
 o shellsort
public static void shellsort(Comparable[] a)
Shellsort, using a sequence suggested by Gonnet.

Parameters:
a - an array of Comparable items.
 o heapsort
public static void heapsort(Comparable[] a)
Standard heapsort.

Parameters:
a - an array of Comparable items.
 o mergeSort
public static void mergeSort(Comparable[] a)
Mergesort algorithm.

Parameters:
a - an array of Comparable items.
 o quicksort
public static void quicksort(Comparable[] a)
Quicksort algorithm.

Parameters:
a - an array of Comparable items.
 o swapReferences
public static void swapReferences(Object[] a,
                                  int index1,
                                  int index2)
Method to swap to elements in an array.

Parameters:
a - an array of objects.
index1 - the index of the first object.
index2 - the index of the second object.
 o quickSelect
public static void quickSelect(Comparable[] a,
                               int k)
Quick selection algorithm. Places the kth smallest item in a[k-1].

Parameters:
a - an array of Comparable items.
k - the desired rank (1 is minimum) in the entire array.

All Packages  Class Hierarchy  This Package  Previous  Next  Index