Two versions of selection sort
问题 Recently i have been looking into sorting algorithms, and like many intro to algorithms books the one I have begun to read starts off with a selection sort implementation. the code went as follows... Implementation A //a is an array of ints. int n = a.length; for(int i = 0; i < n; i ++){ int min =0; for( int x = i+1; x <n;x++){ if(a[x].compareTo(a[i])<0){ Comparable tmp = a[i]; a[i] = a[x]; a[x] = tmp; } } } After analyzing the code block i altered the algorithm to the following.