Tuesday, August 30, 2011

Insertion Sorting

//program of insertion Sorting
#include


#define ELEMENTS 6

void insertion_sort(int x[],int length)
{
int key,i;
for(int j=1;jkey && i>=0)
{
x[i+1]=x[i];
i--;
}
x[i+1]=key;
}
}

int main()
{
int A[ELEMENTS]={5,2,4,6,1,3};
int x;

cout<<"NON SORTED LIST:"< for(x=0;x cout< insertion_sort(A,ELEMENTS);
cout< for(x=0;x cout< return 0;
}
----------------------------------------------------------------------



No comments:

Post a Comment

Total Pageviews