Selection Sort Algorithm in C
selectionSort(array, size)
loop i from 0 to size - 2
set minIndex as i
loop j from first unsorted to size - 1
check if array[j] < array[minIndex]
set minIndex as j
swap array[i] with array[minIndex]
end for
end selectionSort
C Program for Selection Sort
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted subarray and putting it at the beginning of the sorted subarray. In this article, we will learn to write a C program to implement selection sort.
Contact Us