Insertion Sort Algorithm
Insertion sort
We start with the second element of the array as the first element is
assumed to be sorted.
Compare the second element with the first element if the second
element is smaller then swap them.
Move to the third element, compare it with the first two elements, and
put it in its correct position
Repeat until the entire array is sorted
Time complexity: O(N ), (where N = size of the array), for the worst, and
2
average cases.
Space Complexity: O(1)