static void Main() { // TestTheSpeedOfQuickSort(); int size = GetNumFromUser("How many numbers to sort => "); int[] array = GetArrayOfRngs(size); Console.WriteLine($"Sorting {size:n0} numbers"); Print(array); Console.WriteLine(); Sorts.MergeSort(array); Print(array); }
static void TestTheSpeedOfQuickSort() { int size = GetNumFromUser("How many numbers to sort => "); int[] array = GetArrayOfRngs(size); Console.WriteLine($"Sorting {size:n0} numbers"); Console.WriteLine($"Starting the first sort..."); DateTime startTime = DateTime.Now; Sorts.QuickSort(array); TimeSpan firstSort = DateTime.Now - startTime; Console.WriteLine($"Finished the first sort => {firstSort.TotalMilliseconds}(in milliseconds)"); Console.WriteLine("Starting the second sort"); startTime = DateTime.Now; Sorts.ImprovedRearrangeQuickSort(array); //Sorts.QuickSort(array); TimeSpan secondSort = DateTime.Now - startTime; Console.WriteLine($"Finished the second sort => {secondSort.TotalMilliseconds}(in milliseconds)"); }