Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var arr = new[] { 12, 11, 13, 5, 6, 7, 77, 77, 3, 5, 3, 2, 2, 111, 6666, 3, 54 };

            printArray(arr);
            Quick.Sort(arr);
            printArray(arr);

            // quickSort implemented using three way partition, works well for array with duplicate keys,
            // while using old implementation it will take N^2 time average and quicksort loses its effectiveness.
        }
Ejemplo n.º 2
0
 public static void Sort <T>(T[] array) where T : IComparable
 {
     KnuthShuffle(array);
     Quick.Sort(array, 0, array.Length - 1);
 }