Last active
February 22, 2018 16:11
-
-
Save jp26jp/5e86e0383af26fb31221e10094c6eb67 to your computer and use it in GitHub Desktop.
Selection sort algorithm
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[] array) | |
{ | |
for (int i = 0; i < array.length - 1; i++) | |
{ | |
int index = i; | |
for (int j = i + 1; j < array.length; j++) | |
if (array[j] < array[index]) | |
index = j; | |
int temp = array[i]; | |
array[i] = array[index]; | |
array[index] = temp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment