摘要:
只模拟合并的流程 package com.example.sort.merge; public class MergeSort { public static void main(String[] args) { int[] arr = {1, 4, 7, 8, 3, 6, 9}; sort(arr 阅读全文
摘要:
例如1: 1到10的累加 = 55 public class Recursion1 { public static void main(String[] args) { System.out.println(f(10)); } static long f(int n){ if(n<1){ retur 阅读全文
摘要:
间隔大移动次数少,间隔小移动距离短。 public class ShellSort { public static void main(String[] args) { int[] arr = {9, 6, 11, 3, 5, 12, 8, 7, 10, 15, 14, 4, 1, 13, 2}; 阅读全文
摘要:
将数组分成两部分,左侧排序好的,右侧未排序的,然后从右侧拿数据,遍历左侧数据进行比较替换public class InsertionSort { public static void main(String[] args) { int[] arr = {9, 3, 1, 4, 6, 8, 7, 5, 阅读全文
摘要:
package com.example.sort.bubbling; import java.util.Scanner; /** * 9 6 1 3 5 * 6 9 1 3 5 * 6 1 9 3 5 * 6 1 3 9 5 * 6 1 3 5 9 * 第一轮结束 9 从第一位 转移到了最后一位, 阅读全文