Insertion sort is a very simple sorting algorithm,in which the sorted array is built one element at a time.Insertion sort is very less efficient when compared with other more advanced algorithms such as quick sort, heap sort, and merge sort.
INSERTION_SORT (A, N) :
Here A is an unsorted array having N elements.
Step I : Â Â Â Â Repeat Steps 2 to 5 for K = 1 to N
Step II : Â Â Â Â Â Â Â Â Â Set Temp = A [ k ]
Step III : Â Â Â Â Â Â Â Â Â Set J = k – 1
Step IV : Â Â Â Â Â Â Â Â Â Repeat while Temp <= A [ j ]
                        Set A [ j + 1 ] = A [ j ]
                        Set J = j – 1
 [ End of Inner loop ]
Step V : Â Â Â Â Â Â Â Â Â Set A [ j + 1 ] Â = Temp
 [ End of for  Loop ]
Step VI : Â Â Â Exit.
Sorting Steps :
Advantages :-
1. Easy to implement
2. Efficient to use on small sets of data.
3. Requires less memory space.
4. It is twice as fast as the bubble sort, almost 40 % faster than the selection sort.