Instantly share code, notes, and snippets.

# doubledouble/ALG.java Last active Dec 14, 2015

 package test.algorithm; import java.util.Arrays; /** * from wiki http://zh.wikipedia.org/wiki/插入排序 * http://zh.wikipedia.org/wiki/归并排序 **/ public class ALG { /** * @param args */ public static void main(String[] args) { Comparable[] c = {1,5,3,0,9,8}; System.out.println("before sort: " + Arrays.asList(c)); insertionSort(c); System.out.println("after sort: " + Arrays.asList(c)); System.out.println("====================================="); Comparable[] d = {1,5,3,0,9,8}; System.out.println("before sort: " + Arrays.asList(d)); mergeSort(d); System.out.println("after sort: " + Arrays.asList(d)); } public static void insertionSort(Comparable
Owner Author

### doubledouble commented Mar 6, 2013

 before sort: [1, 5, 3, 0, 9, 8] after sort: [0, 1, 3, 5, 8, 9] before sort: [1, 5, 3, 0, 9, 8] sort (0-2, 3-5) [1, 5, 3, 0, 9, 8] sort (0-1, 2-2) [1, 5, 3, 0, 9, 8] sort (0-0, 1-1) [1, 5, 3, 0, 9, 8] merge (0-0, 1-1) [1, 5, 3, 0, 9, 8] merge (0-1, 2-2) [1, 3, 5, 0, 9, 8] sort (3-4, 5-5) [1, 3, 5, 0, 9, 8] sort (3-3, 4-4) [1, 3, 5, 0, 9, 8] merge (3-3, 4-4) [1, 3, 5, 0, 9, 8] merge (3-4, 5-5) [1, 3, 5, 0, 8, 9] merge (0-2, 3-5) [0, 1, 3, 5, 8, 9] after sort: [0, 1, 3, 5, 8, 9]
to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.