Insertion Sort:- The Insertion sort is used to sort an array. The array can be sorted in each round means, In each Iteration of an array the element can be find in sorted.
1: The second element of array compared with the elements will appears before it . If the second element is smaller than first element, they both will interchange their positions. After first iteration, first two elements of an array will be sorted.
2. The third element of an array is compared with the elements that appears before it. If third element is smaller than first element, it is inserted in the position of first element. but in case If third element is larger than first element and smaller than second element, it is inserted in the position of second element. If third element is larger than both the elements, it is kept in the position as it is. After the completion of second iteration, first three elements of an array will be sorted.