Example #1
0
        public static void QuickSort()
        {
            int[] arr;
            FileToArr(out arr);
            Console.WriteLine("- Danh sach ban dau lay tu File:");
            Console.WriteLine("[{0}]", string.Join(", ", arr));
            Console.WriteLine("- Danh sach sau khi duoc sap xep:");
            var sw     = Stopwatch.StartNew();
            var sorter = new QSort <int>(arr);

            sorter.QuickSort(0, arr.Length - 1);
            sw.Stop();
            Console.WriteLine("[{0}]", string.Join(", ", arr));
            Console.WriteLine("Time taken QuickSort: {0} ms", sw.Elapsed.TotalMilliseconds);
            var sw1     = Stopwatch.StartNew();
            var sorter1 = new QSort <int>(arr);

            sorter1.QuickSortDescending(0, arr.Length - 1);
            sw1.Stop();
            Console.WriteLine("[{0}]", string.Join(", ", arr));
            Console.WriteLine("Time taken QuickSort: {0} ms", sw1.Elapsed.TotalMilliseconds);
            Console.ReadKey(true);
        }