Insertion sort is considered as one of simplest of all the sorting algorithms. The strategy behind insertion sort is to pick up an element from the list and place it at the right position in the list at the end of each iteration.

**Algorithm:**

//**Input**: An array of elements to be sorted denoted by ‘A’ and the size of the array denoted by ‘n’

//**Output**: In-place sorted array

//**Requirement**: The contents of the array to be sorted should be comparable with each other i.e. it is expected that relational operations can be applied on the contents of the array.

**procedure insertionSort (A, n)**

for i = 1 to n-1 do

input (A, i, A[i])

done

end

Continue reading “Algorithms – Sorting – Insertion Sort” →