我使用合併排序分割數組後,直到數組長度爲k,我應該在k長度數組上使用插入排序,然後繼續合併。什麼應該是k的最優值?使用插入排序的合併排序的修改版本
另外,我發現與我的類似這些問題,但沒有找到一個明確的答案 Choosing minimum length k of array for merge sort where use of insertion sort to sort the subarrays is more optimal than standard merge sort Modification to merge sort to implement merge sort with insertion sort Java
請注意鏈接的問題使用自底向上合併排序,並開始時將大小爲n的數組視爲大小爲k的n/k個子數組,而不是從頂部向下遞歸分割數組,數組大小<= k。 k的常見值是32,但我不知道它是否最優。 – rcgldr
我的答案錯了嗎? =) – MBo