Udemy: Master Coding Interview - Selection Sort -

Run Settings
LanguageC#
Language Version
Run Command
using System; class MainClass { static void Main() { int[] numbers = {99, 44, 6, 2, 1, 5, 63, 87, 283, 4, 0}; Console.WriteLine(ToString(numbers)); SelectionSort(numbers); Console.WriteLine(ToString(numbers)); } public static void SelectionSort(int[] array) { for (int i = 0; i < array.Length; i++) { int smallestIndex = i; for (int j = i+1; j < array.Length; j++) { if (array[j] < array[smallestIndex]) { smallestIndex = j; } } if (smallestIndex != i) { int temp = array[i]; array[i] = array[smallestIndex]; array[smallestIndex] = temp; } } } public static string ToString(int[] array) { string s = "{"; for (int i = 0; i < array.Length; i++) { if (i > 0) { s += ", "; } s += array[i]; } s += "}"; return s; } }
Editor Settings
Theme
Key bindings
Full width
Lines