| || |
Insertion Sort Program in C
Posted On: 11-Nov-2017 04:34
This is an on-the-spot comparison-based sorting algorithm. In this sort a sub-list is maintained which is always sorted. For example, the lower part of an array is maintained to be sorted. It is named insertion sort as an element which is to be 'insert'ed in this sorted sub-list, has to find its appropriate place and then it has to be inserted there.
The array is searched sequentially and unsorted items are moved and inserted into the sorted sub-list (in the same array). Insertion Sort is not suitable for large data sets as its average and worst case complexity are of Ο(n2), where n is the number of items.
Step 1 − If it is the first element, it is already sorted. return 1;
Active User (9)