Various
Sorting techniques available in Data Structure
1. Bubble Sort
2. Insertion Sort
3. Merge Sort
4. Quick Sort
5. Heap Sort
6. Selection Sort
/* c program to implement insertion sort */
#include<stdio.h>
int main()
{
int a[50],n,i,j,temp;
printf("enter n
value:");
scanf("%d",&n);
printf("Enter %d
numbers:",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
temp=a[i];
for(j=i; j>0 &&
a[j-1]>temp; j--)
a[j]=a[j-1];
a[j]=temp;
}
printf("Sorted array
is:");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
return 0;
}
Output:-
enter n value:5
Enter 5 numbers:9 5 8 2 10
Sorted array is:2 5 8 9 10
Output:-
enter n value:5
Enter 5 numbers:9 5 8 2 10
Sorted array is:2 5 8 9 10

