Selection Sort
Download
source codeJava Code
Warning: Only the algorithm is displayed on this page.Download the source code for a compilable/runnable test, or go here for the complete library of sorting algorithms.
SelectionSort.java
package sorts; /** * SelectionSort.java * Created by Stijn Strickx on May 21, 2008 * Copyright 2008 Stijn Strickx, All rights reserved */ /** * Selection sort algorithm * Time Complexity: O(n*n) * Memory Complexity: O(1) * Stable: yes * Note: Other implementations of the selection sort algorithm might not be stable. */ public class SelectionSort extends Sorter{ @Override public <T extends Comparable<? super T>> void sort(T[] a) { for(int i = 0; i < a.length; i++){ int min = i; for(int j = i+1; j