Selection Sort
Finds the smallest element in the array and swaps it with the first element, the next smallest element and swaps it with the second element, etc. (see sort.c)
I = 0;
minI = I; /* start here */
for (j = I + 1; j < SIZE ; j++) {
if (ar[j] < ar[minI]) {
minI = j; /* save it */
}
}
Previous slide
Next slide
Back to first slide
View graphic version