selection sort in c#
Algorithm 2020. 10. 14. 14:14stackabuse.com/selection-sort-in-javascript/
Selection Sort in JavaScript
Introduction Selection Sort is one of the simpler and more intuitive sorting algorithms. It is an in-place, unstable, comparison algorithm. This means that it transforms the input collection using no auxiliary data structures and that the input is overridd
stackabuse.com
www.tutorialspoint.com/selection-sort-program-in-chash
Selection Sort program in C#
Selection Sort program in C# Selection Sort is a sorting algorithm that finds the minimum value in the array for each iteration of the loop. Then this minimum value is swapped with the current array element. This procedure is followed until the array is so
www.tutorialspoint.com
using System;
namespace SelectSort {
class Program {
static void Main (string[] args) {
int[] arr = { 4, 1, 5, 3, 2 };
int n = arr.Length;
int smallest;
int temp;
for (int i = 0; i < n - 1; i++) {
smallest = i;
for (int j = i + 1; j < n; j++) {
if (arr[j] < arr[smallest]) {
smallest = j;
}
}
temp = arr[smallest];
arr[smallest] = arr[i];
arr[i] = temp;
}
foreach (var num in arr) {
Console.WriteLine (num);
}
}
}
}
'Algorithm' 카테고리의 다른 글
실전 알고리즘 강좌 바킹독 (0) | 2020.10.23 |
---|---|
선택정렬 (Selection Sort) C# (0) | 2020.10.23 |
고정배열을 구현한 Queue (0) | 2020.10.07 |
원형배열로 구현한 Queue (0) | 2020.10.07 |
C#으로 구현한 링크드리스트 (0) | 2020.04.16 |