public static void Test_List_OP(int seed) { int n = 12; Console.WriteLine("\n Selection sort LIST: \n"); MyDataList myList = new MyDataList(n); myList.Print(n); myList.SelectionSort(); myList.Print(n); Console.WriteLine("\n Quick sort LIST: \n"); MyDataList myList2 = new MyDataList(n); myList2.Print(n); myList2.QuickSort(myList2, 0, myList2.Length - 1); myList2.Print(n); Console.WriteLine(); Console.WriteLine("____________________________________________________________"); Console.WriteLine("____________________________________________________________"); }
public static void OP_Sort_Speed_Test() { Console.WriteLine(); Console.WriteLine(" Speed test OP: "); Console.WriteLine("\n Selection sort ARRAY: \n"); int[] length = { 400, 800, 1600, 3200, 6400, 12800, 25600 }; for (int i = 0; i < length.Length; i++) { MyDataArray n = new MyDataArray(length[i]); Stopwatch t = new Stopwatch(); t.Start(); n.SelectionSort(); t.Stop(); TimeSpan e = t.Elapsed; Console.WriteLine("Amount of data: {0,5} --->>> Time elapsed: {1}", length[i], e.ToString()); } Console.WriteLine(); Console.WriteLine("\n Selection sort LIST: \n"); for (int i = 0; i < length.Length; i++) { MyDataList n = new MyDataList(length[i]); Stopwatch t = new Stopwatch(); t.Start(); n.SelectionSort(); t.Stop(); TimeSpan e = t.Elapsed; Console.WriteLine("Amount of data: {0,5} --->>> Time elapsed: {1}", length[i], e.ToString()); } Console.WriteLine(); Console.WriteLine("------------------------------------------------------------"); Console.WriteLine("\n Quick sort ARRAY: \n"); for (int i = 0; i < length.Length; i++) { MyDataArray n = new MyDataArray(length[i]); Stopwatch t = new Stopwatch(); t.Start(); n.QuickSort(); t.Stop(); TimeSpan e = t.Elapsed; Console.WriteLine("Amount of data: {0,5} --->>> Time elapsed: {1}", length[i], e.ToString()); } Console.WriteLine(); Console.WriteLine("\n Quick sort LIST: \n"); for (int i = 0; i < length.Length; i++) { MyDataList n = new MyDataList(length[i]); Stopwatch t = new Stopwatch(); t.Start(); n.QuickSort(n, 0, n.Length - 1); t.Stop(); TimeSpan e = t.Elapsed; Console.WriteLine("Amount of data: {0,5} --->>> Time elapsed: {1}", length[i], e.ToString()); } Console.WriteLine("____________________________________________________________"); Console.WriteLine("____________________________________________________________"); }