In: Computer Science
Consider a sorting algorithm that combines merge sort and insertion sort algorithm. We still use divide and conquer like merge sort, however when the number of elements in an array is at most k elements (k is a parameter), we stop dividing the elements as the regular merge sort, instead, we call the insertion sort. Assuming we have defined the following two procedures:
insertion-sort(A[p..q]) which sort the subarray A[p..q]
merge(A[p,q,r]) which merges the sorted subarray A[p..r] and A[r+1..q]
merge-insert(A[p..q], k)
at
the end of for loop for combining the array usiing merge sort then
we will get a sorted array x