net.datastructures - version 5.0

net.datastructures
Class Sort

java.lang.Object
  extended by net.datastructures.Sort

public class Sort
extends Object

Class containing various sorting algorithms.

Author:
Michael Goodrich, Roberto Tamassia, Eric Zamore

Constructor Summary
Sort()
           
 
Method Summary
static void main(String[] argv)
           
protected static
<E> void
merge(E[] in, E[] out, Comparator<E> c, int start, int inc)
          Merges two subarrays, specified by a start and increment.
static
<E> void
merge(PositionList<E> in1, PositionList<E> in2, Comparator<E> c, PositionList<E> in)
          Merges two sorted lists, in1 and in2, into a sorted list in.
static
<E> void
mergeSort(E[] orig, Comparator<E> c)
          Sorts an array with a comparator using nonrecursive merge sort.
static
<E> void
mergeSort(PositionList<E> in, Comparator<E> c)
          Sorts the elements of list in in nondecreasing order according to comparator c, using the merge-sort algorithm.
static
<E> void
quickSort(E[] s, Comparator<E> c)
          Sorts the elements of array s in nondecreasing order according to comparator c, using the quick-sort algorithm.
static
<E> void
quickSort(PositionList<E> in, Comparator<E> c)
          Sorts the elements of list in in nondecreasing order according to comparator c, using a list-based implementation of the deterministic quicksort algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sort

public Sort()
Method Detail

mergeSort

public static <E> void mergeSort(PositionList<E> in,
                                 Comparator<E> c)
Sorts the elements of list in in nondecreasing order according to comparator c, using the merge-sort algorithm.


merge

public static <E> void merge(PositionList<E> in1,
                             PositionList<E> in2,
                             Comparator<E> c,
                             PositionList<E> in)
Merges two sorted lists, in1 and in2, into a sorted list in.


mergeSort

public static <E> void mergeSort(E[] orig,
                                 Comparator<E> c)
Sorts an array with a comparator using nonrecursive merge sort.


merge

protected static <E> void merge(E[] in,
                                E[] out,
                                Comparator<E> c,
                                int start,
                                int inc)
Merges two subarrays, specified by a start and increment.


quickSort

public static <E> void quickSort(PositionList<E> in,
                                 Comparator<E> c)
Sorts the elements of list in in nondecreasing order according to comparator c, using a list-based implementation of the deterministic quicksort algorithm.


quickSort

public static <E> void quickSort(E[] s,
                                 Comparator<E> c)
Sorts the elements of array s in nondecreasing order according to comparator c, using the quick-sort algorithm. Most of the work is done by the auxiliary recursive method quickSortStep.


main

public static void main(String[] argv)
                 throws IOException
Throws:
IOException

net.datastructures - version 5.0