Selection Sort
Here we analyze the selection sort algorithm, which repeatedly indentifies the smallest remaining unsorted element and puts it at the end of the sorted of the array.
View Code
1 Selection_Sort(int s[], int n)
2 {
3 int i,j;
4 int min;
5
6 for(i = 0; i < n; i++)
7 {
8 min = i;
9 for(j = i + 1; j < n; j++)
10 if(s[j] < s[min])
11 min = j;
12
13 Swap(&s[i], &s[min]);
14 }
15 }