摘要: //二分查找的前提是有序的数。public class BinarySearch { public static void main(String[] args) { int[] arr = {1, 2, 4, 5, 6, 8, 9, 10}; System.out.println(binarySe 阅读全文
posted @ 2019-04-28 15:33 jason小蜗牛 阅读(176) 评论(0) 推荐(0) 编辑
摘要: //选择排序//基本思想:从原始数组中寻找最小的那个数,然后与第一个数交换,依次类推public class SelectionSort { public static void main(String[] args) { int[] arr = {1, 4, 15, 63, 33, -1, 0, 阅读全文
posted @ 2019-04-28 14:56 jason小蜗牛 阅读(217) 评论(0) 推荐(0) 编辑
摘要: //插入排序//从第一个元素开始,每个数往前插入,后一个数与前一个数相比较,如果后一个数小于前一个数,则将后一个数往前移位。public class InsertSort { public static void main(String[] args) { int[] arr = {-2, 52, 阅读全文
posted @ 2019-04-28 14:50 jason小蜗牛 阅读(198) 评论(0) 推荐(0) 编辑