com.mhhe.clrs2e
Class Quicksort

java.lang.Object
  |
  +--com.mhhe.clrs2e.Quicksort
All Implemented Interfaces:
Sorter
Direct Known Subclasses:
RandomizedQuicksort

public class Quicksort
extends java.lang.Object
implements Sorter

Implements the Sorter interface via quicksort from page 146 of Introduction to Algorithms, Second edition.


Field Summary
protected  com.mhhe.clrs2e.Partitioner part
          An object for partitioning; may be either deterministic or randomized.
 
Constructor Summary
Quicksort()
           
 
Method Summary
protected  void quicksort(java.lang.Comparable[] array, int p, int r)
          Recursive quicksort procedure to sort the subarray array[p..r].
 void sort(java.lang.Comparable[] array)
          Sorts an array of Comparable objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

part

protected com.mhhe.clrs2e.Partitioner part
An object for partitioning; may be either deterministic or randomized.

Constructor Detail

Quicksort

public Quicksort()
Method Detail

quicksort

protected void quicksort(java.lang.Comparable[] array,
                         int p,
                         int r)
Recursive quicksort procedure to sort the subarray array[p..r]. Uses whatever partitioner the instance variable part is set to.

Parameters:
array - The array containing the subarray to be sorted.
p - Index of the beginning of the subarray.
r - Index of the end of the subarray.

sort

public void sort(java.lang.Comparable[] array)
Sorts an array of Comparable objects.

Specified by:
sort in interface Sorter
Parameters:
array - The array of Comparable objects to be sorted.