Implementation of Insertion Sort| Sorted list | Unsorted list |output

Program for implementation of Insertion Sort


#include

#include
#define max 20

void main()

{
int i,j,n,k,t,temp,a[max];
clrscr();
printf("\How many no. you want to insert into list:- ");
scanf("%d",&n);
for(i=0;ij;k--)
a[k]=a[k-1];
a[k+1]=temp;
}
}
}
printf("\n\nSorted list is:-\n");
for(i=0;i

Output:-

How many no. you want to insert into list:- 5


Enter 1 no:- 4

Enter 2 no:- 3
Enter 3 no:- 5
Enter 4 no:- 2
Enter 5 no:- 1

Unsorted list is:-


4

3
5
2
1

Sorted list is:-


1

2
3
4
5

*/

0 comments:

Post a Comment