Data structures and
Algorithms
Title : comparison of
Selection sort, Bubble Sort,
Insertion Sort.
,Selection Sort :
Selection sort is a simple and efficient
sorting algorithm that works by
repeatedly selecting the smallest (or
largest) element from the unsorted
portion of the list and moving it to the
sorted portion of the list.
Program :
#include<stdio.h>
void main()
{
, int i,n,a[10],data,t,min, count=0,swap=0,j;
printf("enter the number of elements in
the array\n");
scanf("%d",&n);
printf("enter the elements");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
min=i;
for(j=i+1;j<n;j++)
{
count=count+1;
if(a[min]>a[j])
{
min=j;
}
if(i!=min)
{
swap=swap+1;
t=a[i];
a[i]=a[min];
a[min]=t;
Algorithms
Title : comparison of
Selection sort, Bubble Sort,
Insertion Sort.
,Selection Sort :
Selection sort is a simple and efficient
sorting algorithm that works by
repeatedly selecting the smallest (or
largest) element from the unsorted
portion of the list and moving it to the
sorted portion of the list.
Program :
#include<stdio.h>
void main()
{
, int i,n,a[10],data,t,min, count=0,swap=0,j;
printf("enter the number of elements in
the array\n");
scanf("%d",&n);
printf("enter the elements");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
min=i;
for(j=i+1;j<n;j++)
{
count=count+1;
if(a[min]>a[j])
{
min=j;
}
if(i!=min)
{
swap=swap+1;
t=a[i];
a[i]=a[min];
a[min]=t;