Social Sciences, asked by fardeen41, 11 months ago

what is insertion sort in programming c

Answers

Answered by Anonymous
2
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such asquicksort, heapsort, or merge sort..

MARK BRAINLIEST...
Answered by samarthkrv
0

Answer:

#include<stdio.h>

void insertion_sort(int arr[] , int len)

{

for(int i = 0; i < len-1; i++)

{

int current = arr[i];

int j = i - 1;

 while(j >= 0 && arr[j] > current)

 {

 arr[j + 1] = arr[j];

 j--;

 }

arr[j + 1] = current;

}

}

int main()

{

int arr[] = {9,8,4,5,2,7,1,3,0,2};

int len = sizeof(arr) / sizeof(arr[0]);

insertion_sort(arr , len);

for(int i = 0; i < len; i++)

{

printf("%d " , arr[i]);

}

return 0;

}

Explanation:

Similar questions