public MainClass() { HeapSort heapSort = new HeapSort(); CombSort CombSort = new CombSort(); ArrayGenerator arrays = new ArrayGenerator(); int[] array1 = arrays.generateRandomArray(10); int[] array2 = arrays.generateRandomArray(100); //int[] array3 = arrays.generateRandomArray(1000); //int[] array4 = arrays.generateRandomArray(10000); // int[] array5 = arrays.generateRandomArray(100000); // int[] array6 = arrays.generateRandomArray(1000000); DateTime time1 = DateTime.Now; heapSort.sort(array1); DateTime time2 = DateTime.Now; TimeSpan total = new TimeSpan(time2.Ticks - time1.Ticks); Console.WriteLine(total.TotalMilliseconds + ""); DateTime time3 = DateTime.Now; heapSort.sort(array2); DateTime time4 = DateTime.Now; TimeSpan total1 = new TimeSpan(time3.Ticks - time4.Ticks); Console.WriteLine(total.TotalMilliseconds + ""); // sw.Write("Inverso MergeSort = " + total.TotalMilliseconds + "\n"); Console.ReadKey(true); }
static void Main(string[] args) { //Generate random 1D array int[] myArray = ArrayGenerator(); int[] myTempArray = new int[myArray.Length]; Array.Copy(myArray, myTempArray, myArray.Length); //Print the unsorted list to the console so it can be checked Console.WriteLine("Unsorted list:"); foreach (int element in myArray) { Console.WriteLine(element); } Console.WriteLine(); //Calling different sorting algorithms on the list and putting the results into TXTs Console.WriteLine("Check on array that has duplicates:"); Console.WriteLine(); BubbleSort.BubbleSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); SelectionSort.SelectionSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); //MergeSort.MergeSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); InsertionSort.InsertionSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); BucketSort.BucketSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); QuickSort.QuickSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); GnomeSort.GnomeSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); CombSort.CombSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); CountingSort.CountingSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); HeapSort.HeapSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); //CycleSort.CycleSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); //BogoSort.BogoSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); CocktailSort.CocktailSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); StoogeSort.StoogeSortAlgorithm(new int[] { 2, 4, 5, 3, 1 }); myTempArray.CopyTo(myArray, 0); OddEvenSort.OddEvenSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); BubbleSortRecursive.BubblesortRecursiveAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); //InsertionSortRecursive.InsertionSortRecursiveAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); //ShellSort.ShellSortAlgorithm(myArray); myTempArray.CopyTo(myArray, 0); StrandSort.StrandSortAlgorithm(new int[] { 3, 5, 5, 1, 5, 3, 10, 8, 9 }); myTempArray.CopyTo(myArray, 0); // Console.ReadKey(); }