Terry's blog

Focus on bigdata and cloud.

博客园 首页 新随笔 联系 订阅 管理
  383 随笔 :: 1 文章 :: 268 评论 :: 83万 阅读

随笔分类 -  数据结构

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

摘要:冒泡算法: 基本思想:两两比较待排序数据元素的大小,发现两个数据元素的次序相反时即进行交换,直到没有反序的数据元素为止。 代码实现: public class BubbleSorter { public void Sort(int [] list) { int i,j,temp; bool done=fals... 阅读全文
posted @ 2007-11-23 17:53 王晓成 阅读(309) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示