According to here
Use insertion sort...for invocations on small arrays (i.e. where the length is less than a threshold k determined experimentally). This can be implemented by simply stopping the recursion when less than k elements are left, leaving the entire array k-sorted: each element will be at most k positions away from its final position. Then, a single insertion sort pass finishes the sort in O(k×n) time.
I'm not sure I'm understanding correctly. One way to do it that involves calling insertion sort multiple times is
quicksort(A, i, k):
if i+threshold < k:
p := partition(A, i, k)
quicksort(A, i, p - 1)
quicksort(A, p + 1, k)
else
insertionsort(A, i, k)
but this would call insertionsort()
for each subarray. It sounds like insertion sort could be called only once, but I sort of don't understand this because it doesn't matter how many times insertion sort is called it's still generally slower than quicksort.
Is the idea like this?
sort(A)
quicksort(A, 0, A.length-1)
insertionsort(A, 0, A.length-1)
So basically call insertion sort once at the very end? How do you know it would only take one pass and not run at O(n)?