PROGRAM OF INSERTION SORT OPERATION IN C LANGUAGE
#include<stdio.h>
void printarray(int* A,int n){
for(int i=0;i<n;i++){
printf("%d ",A[i]);
}
printf("\n");
}
void insertion(int *A,int n){
int key,j;
for(int i=1;i<=n-1;i++){
key=A[i];
j=i-1;
while(j>=0 && A[j] > key){
A[j+1]=A[j];
j--;
}
A[j+1]=key;
}
}
int main()
{
int A[]={55,8,5,44,58,24};
int n=6;
printarray(A,n);
insertion(A,n);
printarray(A,n);
return 0;
}
0 Comments