Implementation of Selection sort in C
suggest changeI used C# language to implement Selection sort algorithm.
public class SelectionSort { private static void SortSelection(int[] input, int n) { for (int i = 0; i < n - 1; i++) { var minId = i; int j; for (j = i + 1; j < n; j++) { if (input[j] < input[minId]) minId = j; } var temp = input[minId]; input[minId] = input[i]; input[i] = temp; } } public static int[] Main(int[] input) { SortSelection(input, input.Length); return input; } }
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents