Sorting Algorithms (bubble sort, merge sort)
What optimization strategy is demonstrated in this hybrid sorting approach?
function hybridSort(arr, threshold = 10) {
if (arr.length <= threshold) {
return bubbleSort(arr);
}
const mid = Math.floor(arr.length / 2);
const left = hybridSort(arr.slice(0, mid), threshold);
const right = hybridSort(arr.slice(mid), threshold);
return merge(left, right);
}