pure-jcore/src/main/java/leetcode/MedianofTwoSortedArrays.java
// select the greatest or the smallest
select the greatest or the smallest
select the greatest or the smallest
public void selectionSort(int[] arr) {
    	int ind = 0, temp = 0, len = arr.length;
    	for (int i=0;i<arr.length;i++) { 
    		ind = 0;
    		for (int j=0;j<arr.length - i;j++) { 
    			if (arr[j] > arr[ind]) {
    				ind = j;
    			}
    		}
    		temp = arr[ind];
    		arr[ind] = arr[len - i -1]; 
    		arr[len - i - 1] = temp;
    	}
    	printArray(arr);
    }
public void selectionSort ( int [ ] arr ) { int ind = 0 , temp = 0 , len = arr . length ; for ( int i = 0 ; i < arr . length ; i ++ ) { ind = 0 ; for ( int j = 0 ; j < arr . length - i ; j ++ ) { if ( arr [ j ] > arr [ ind ] ) { ind = j ; } } temp = arr [ ind ] ; arr [ ind ] = arr [ len - i - 1 ] ; arr [ len - i - 1 ] = temp ; } printArray ( arr ) ; }
select the greatest or the smallest
select the greatest or the smallest
// loop for all - 1 largest nums // for all - i largest position // swap the value