Edmund's zone

导航

公告

随笔分类

随笔档案

最新评论

统计

常用链接

阅读排行榜

评论排行榜

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 }



posted on 2011-11-14 17:50 Edmund Li 阅读(14) 评论(0) 编辑 收藏