随笔分类 - 数据结构与算法
If you want to become a good programmer, you can spend 10 years programming, or spend 2 years programming and learning algorithms.
摘要:上一篇博文说到了插入排序,如果我将内循环中的较大元素都向右移动,而不是总是两两之间进行交换。这个把较大元素不断上浮的算法就是大家经常说的冒泡排序 1 public class BubbleSort 2 { 3 public static void sort(int[] a) 4 { ...
阅读全文
摘要: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]) ...
阅读全文
摘要:1 public class SlectedSort 2 { 3 public static void sort(int[] a) 4 { 5 int N = a.length; 6 for (int i = 0; i < N; i++) 7 ...
阅读全文

浙公网安备 33010602011771号