/** * The idea of choosing a sort: * to find the smallest element each time from the list to be sorted, * then place it on the leftmost of the sequence to be sorted until all elements are ordered * * Select sort to improve the bubble sort, reduce the number of exchanges from O (n^2) to O (N) * But compare the Times or O
(N) */package Al; public class Selectsort {public static void main (string[] args) {Selectsort selectsort = new Selectsor
T ();
Int[] elements = {14, 77, 21, 9, 10, 50, 43, 14};
Sort the array selectsort.sort (elements);
Print the sorted array for (int i = 0; i < elements.length i++) {System.out.print (elements[i));
System.out.print (""); }/** * @author * @param array to row arrays */public void sort (int[] array) {//min to save
Minimum element for each round int min, tmp;
for (int i=0; i<array.length; i++) {min = i;
Search for the minimum element for (int j=i; j<array.length; J + +) {if (Array[j] < array[min]) {
min = j; }//swap minimum element TMP = arrAy[i];
Array[i] = Array[min];
Array[min] = tmp;
}
}
}