Algorithm of The Day: Insertion Sort

Insertion sort is an efficient algorithm for sorting a small number of elements. It is basically sorting a random array of numbers in an ascending or descending order depending on our choice of design.

The most popular example of this could be sorting a deck of cards. Imagine having a deck in your right hand in a random order. You will need to check the cards one by one and compare with each other until it is sorted.

or more technically;

Imagine having this integer array : {7,4,2,5,1,3,6} Starting from the second element, we need to compare it with the previous number until the array is sorted.

It is relatively fast for a small group of numbers, whereas merge sort is much more effective for large amount of numbers.