Ejemplo n.º 1
0
    public static void Test()
    {
        int[] a = { 5, 8, 1, 9, 3, 5, 7, 1, 2 };
        Print(a);
        System.Console.WriteLine("Bubble sort: T=O(n^2)");
        BubbleSort(a);
        Print(a);
        int[] b = { 5, 8, 1, 9, 3, 5, 7, 1, 2 };

        System.Console.WriteLine("Simple selection sort: T=O(n^2), swap count less than bubble sort.");
        SimpleSelectionSort(b);
        Print(b);

        Heap.BuildMarxHeap();
        System.Console.WriteLine("Heap sort: T= O(nlogn), better for big number");

        b = new int[] { 5, 8, 1, 9, 3, 5, 7, 1, 2 };
        InsertionSort(b);
        System.Console.WriteLine("Insert sort: T= O(n^2), better for big number");

        Print(b);
        System.Console.WriteLine("Quick Sort O(nlogn)");
        b = new int[] { 5, 8, 1, 9, 3, 5, 7, 1, 2 };

        QuickSort(b);
        Print(b);
        System.Console.WriteLine("Shell Sort O(nlogn)");
        b = new int[] { 5, 8, 1, 9, 3, 5, 7, 1, 2 };

        ShellShort(b);
        Print(b);
    }