private static void TestSort(int[] array) { Console.WriteLine("Test array - Insertion sort -> Merge sort -> Quick sort -> Linear sort:"); Print(array); var st = new Stopwatch(); st.Start(); var result = new InsertionSort <int>().Sort(array); st.Stop(); Console.WriteLine(st.ElapsedMilliseconds); Print(result); st.Restart(); result = new MergedSort <int>().Sort(array); st.Stop(); Console.WriteLine(st.ElapsedMilliseconds); Print(result); st.Restart(); result = new QuickSort <int>().Sort(array); st.Stop(); Console.WriteLine(st.ElapsedMilliseconds); Print(result); st.Restart(); result = new LinearSort().Sort(array); st.Stop(); Console.WriteLine(st.ElapsedMilliseconds); Print(result); }
public void TestBubbleSort() { int[] array = { 4, 7, 2, 3, 9, 8, 0, 1, 5, 6 }; LinearSort.BubbleSort(array); foreach (int i in array) { Console.Write(i + " "); } }