Insertion Sort: Algorithm, Working, Example, and Analysis
Insertion Sort: Algorithm, Working, Example, and Analysis
Even though insertion sort is efficient, still, if we provide an already sorted array to the
insertion sort algorithm, it will still execute the outer for loop, thereby requiring n steps to
sort an already sorted array of n elements, which makes its best case time complexity a
linear function of n.
Space Complexity: O(1)