SELECTION SORT

Selection Sort for sorting a list L of n numbers, represented by an array A[1 . . n], proceeds by finding the minimum element of the array and placing it in the first position of the array representing the list. Then repeat the process on the subarray representing the sublist obtained from the list by excluding the current minimum element.

Selection Sort Programming in C

#include<stdio.h>
void main()
{
int a[]={ 80, 32, 28, 110, 50 };
int i, j, temp, index;
for(i=0; i<4; i++)
{
index = i;
for(j=i+1; j<5; j++)
{
if(a[index] > a[j])
index = j;
}
if(index != i)
{
temp=a[i];
a[i]=a[index];
a[index]=temp;
}
}
for(i=0; i<5; i++)
{
printf("\t%d",a[i]);
}
}

QuestionSolves.com is an educational website that helps worldwide students in solving computer education related queries.

Also, different software like Visual Studio, SQL Server, Oracle etc. are available to download in different versions.

Moreover, QuestionSolves.com provides solutions to your questions and assignments also.

MORE TOPIC

WHAT WE DO