private static void SelectionSortTest() { Console.WriteLine("Selection Sort Test"); int[] arr = new int[_arr.Length]; Array.Copy(_arr, arr, _arr.Length); ISortAble selectionSort = new SelectionSort(); selectionSort.StartTimer(); int[] sorted = selectionSort.Sort(arr); selectionSort.StopTimer(); if (_printArray) { selectionSort.PrintArray(arr); } selectionSort.PrintElapsedTime(); selectionSort.ResetTimer(); }
private static void TestSelectionSort() { var array = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 }; SelectionSort.Sort(array); Console.WriteLine(string.Join(", ", array)); }
public static void Execute() { var a = new int[] { 2, 3, 6, 5, 1, 4 }; SelectionSort <int> .Sort(a); System.Console.WriteLine("Complete"); }
private static void ExecuteSelectionSort() { var array = new int[] { 7, 2, 5, 9, 1, 13, 3 }; Console.WriteLine($"Selection sort - {string.Join(",", array)}"); var sorter = new SelectionSort(); sorter.Sort(array); Console.WriteLine($"Sorted array - {string.Join(",", array)}"); }
static void Main(string[] args) { int[] items = { 4, 6, 8, 0, 2, 7, 3, 3 }; SelectionSort.Sort(items); foreach (var n in items) { Console.Write(n + " "); } Console.WriteLine(); }
public void SelectionSortTest() { // Arrange var arrayCount = 0; foreach (var sample in GenerateSampleArrays()) { // Act SelectionSort.Sort(sample); // Assert for (int i = 0; i < sample.Length - 1; i++) { Assert.True(sample[i] <= sample[i + 1], $"Array #{arrayCount} was not sorted."); arrayCount++; } } }