随笔分类 - 算法
摘要:/** * 冒泡排序的核心就是,按顺序进行两两比较,如果第一个比第二个大则交换位置 */ public class MaoPaoPaiXu { private static int[] bubbleSort(int[] a) { // 至少进行n-1轮比较 for (int i = 0; i a[j + 1]) { ...
阅读全文
摘要:public class BinarySearch { public static void main(String[] args) { int[] a = {1,2,3,4,5,6,7,8,9}; int binarySerach = binarySerach(a, 4); System.out.println(binarySe...
阅读全文