net.datastructures
Class Sort

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

public class Sort
extends java.lang.Object

Class containing various sorting algorithms.

Author:
Michael Goodrich, Roberto Tamassia, Eric Zamore

Constructor Summary
Sort()
           
 
Method Summary
static void main(java.lang.String[] argv)
           
static
<E> void
merge(PositionList<E> in1, PositionList<E> in2, java.util.Comparator<E> c, PositionList<E> in)
          Merges two sorted lists, in1 and in2, into a sorted list in.
static
<E> void
mergeSort(E[] orig, java.util.Comparator<E> c)
          Sorts an array with a comparator using nonrecursive merge sort.
static
<E> void
mergeSort(PositionList<E> in, java.util.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, java.util.Comparator<E> compare)
          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, java.util.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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sort

public Sort()
Method Detail

mergeSort

public static <E> void mergeSort(PositionList<E> in,
                                 java.util.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,
                             java.util.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,
                                 java.util.Comparator<E> c)
Sorts an array with a comparator using nonrecursive merge sort.


quickSort

public static <E> void quickSort(PositionList<E> in,
                                 java.util.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,
                                 java.util.Comparator<E> compare)
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(java.lang.String[] argv)
                 throws java.io.IOException
Throws:
java.io.IOException