Regarding the number of elements are <= 47, does this only happen if the whole array .sort() is called on is <= 47, or does the DualPivotQuickSort algorithm use Insertion Sort to sort partitions of length <= 47 instead of recursing DPQS on it??
DualPivotQuickSort class has a threshold of '47' defined for number of elements in an array. If number of elements are lesser than threshold then sorting function uses insertion sort.
Below snippet is from Java docs.
private static final int INSERTION_SORT_THRESHOLD = 47;
// Use insertion sort on tiny arrays
if (length < INSERTION_SORT_THRESHOLD) {
if (leftmost) {
...
...
Regarding the
number of elements are <= 47, does this only happen if the whole array.sort()is called on is <= 47, or does theDualPivotQuickSortalgorithm use Insertion Sort to sort partitions of length<= 47instead of recursing DPQS on it??DualPivotQuickSort class has a threshold of '47' defined for number of elements in an array. If number of elements are lesser than threshold then sorting function uses insertion sort.
Below snippet is from Java docs.
private static final int INSERTION_SORT_THRESHOLD = 47;
Yeah, but, is this inside or outside the function that recurses?