摘要: 上一篇博文说到了插入排序,如果我将内循环中的较大元素都向右移动,而不是总是两两之间进行交换。这个把较大元素不断上浮的算法就是大家经常说的冒泡排序 1 public class BubbleSort 2 { 3 public static void sort(int[] a) 4 { ... 阅读全文
posted @ 2014-05-15 21:23 owen-beta 阅读(211) 评论(0) 推荐(0) 编辑
摘要: public class InsertSort{ public static void sort(int[] a) { int N = a.length; int count = 0; for (int i = 1; i 0; j--) { if (a[j] < a[j-1]) ... 阅读全文
posted @ 2014-05-15 21:16 owen-beta 阅读(156) 评论(0) 推荐(0) 编辑