What is insertion sort?
when does it stop?
what is the time complexity?
what is the worst case scenario?
An array is divided into a sorted part and an unsorted part.
The insertion sort algorithm moves elements one at a time from the unsorted part into the correct position of the sorted part.
This process continues until all the elements have been sorted.
Time complexity: O(n2) for the general case, O(n)for the best case where all the elements are already sorted in the correct order.
The worst case scenario is when the elements in the array are in reverse order.