Terry's blog

Focus on bigdata and cloud.

博客园 首页 新随笔 联系 订阅 管理

2007年11月26日 #

摘要: 基本思想: 每一趟从待排序的数据元素中选出最小(或最大)的一个元素,顺序放在已排好序的数列的最后,直到全部待排序的数据元素排完。 代码实例: public class SelectionSorter { private int min; public void Sort(int [] list) { for(int i=0;i<list.Leng... 阅读全文
posted @ 2007-11-26 09:48 王晓成 阅读(313) 评论(0) 推荐(0) 编辑

摘要: 基本思想: 每次将一个待排序的数据元素,插入到前面已经排好序的数列中的适当位置,使数列依然有序;直到待排序数据元素全部插入完为止。 实例代码: public class InsertionSorter { public void Sort(int [] list) { for(int i=1;i0)&&(list[j-1]>t)) {... 阅读全文
posted @ 2007-11-26 09:34 王晓成 阅读(305) 评论(0) 推荐(0) 编辑