The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
Selection sort algorithm is also called as Exchange sort algorithm. The technique of sorting selection sort algorithm is very simple as shown below.
step 1: It search for the first smallest element in the array and swap it with a element array[0].
step 2: Then it search for second smallest element in the array and swap it with a element array[1].
step 3: This process will be repeated until the n-1 element in an array is sorted.
Here is the program to demonstrate Selection Sort.
#include <stdio.h> int smallest (int arry[], int k, int n); void selection_sort(int arry[], int n); int main() { int arry[10],i,n; printf("\n Enter the size of the array : "); scanf("%d", &n); printf("\n Enter %d elements in the array : \n",n); for(i=0; i
Enter the size of the array : 5 Enter 5 elements in the array : 4 3 1 2 5 Sorted Array in ascending order is : 1 2 3 4 5
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019