Last active
January 24, 2018 12:02
-
-
Save keehyun2/597d0baf70a3c18cee806da4f9eee56d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void selectionSort(int[] arr){ | |
for(int i = arr.length - 1; i > 0; i --) { | |
int maxIndex = 0 ; // 배열 원소중 max 값의 index를 저장할 변수 | |
for(int j = 1; j <= i ; j++) | |
if(arr[j] > arr[maxIndex]) maxIndex = j; | |
swap(arr, maxIndex, i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment