Class Select

java.lang.Object
  extended by Select

public class Select
extends java.lang.Object

The Select Java application illustrates a selection sort.

Java Source Code for this class:
http://www.cs.colorado.edu/~main/applications/Select.java


Constructor Summary
Select()
           
 
Method Summary
static void main(java.lang.String[] args)
          The main method illustrates the use of a selection sort to sort a small array.
static void selectionsort(int[] data, int first, int n)
          Sort an array of integers from smallest to largest, using a selection sort algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Select

public Select()
Method Detail

main

public static void main(java.lang.String[] args)
The main method illustrates the use of a selection sort to sort a small array. The String arguments (args) are not used in this implementation.


selectionsort

public static void selectionsort(int[] data,
                                 int first,
                                 int n)
Sort an array of integers from smallest to largest, using a selection sort algorithm.

Parameters:
data - the array to be sorted
first - the start index for the portion of the array that will be sorted
n - the number of elements to sort
Precondition:
data[first] through data[first+n-1] are valid parts of the array.
Postcondition:
If n is zero or negative then no work is done. Otherwise, the elements of data have been rearranged so that data[first] <= data[first+1] <= ... <= data[first+n-1].
Throws:
java.lang.ArrayIndexOutOfBoundsException - Indicates that first+n-1 is an index beyond the end of the array.