Content deleted Content added
m David Eppstein moved page Merge-insert sort to Merge-insertion sort: Follow Knuthian nomenclature |
Follow Knuthian nomenclature |
||
Line 1:
In [[computer science]], '''merge-
==Algorithm==
Merge-
#Group the elements of <math>X</math> into <math>\lfloor n/2\rfloor</math> pairs of elements, arbitrarily, leaving one element unpaired if there is an odd number of elements.
#Perform <math>\lfloor n/2\rfloor</math> comparisons, one per pair, to determine the larger of the two elements in each pair.
Line 20:
==Analysis==
Let <math>C(n)</math> denote the number of comparisons that merge-
This number of comparisons can be broken down as the sum of three terms:
*<math>\lfloor n/2\rfloor</math> comparisons among the pairs of items,
Line 34:
==Relation to other comparison sorts==
The algorithm is called merge-
while the comparisons that it performs after the recursive call (using binary search to insert elements one by one into a sorted list) follow the same principal as [[insertion sort]]. In this sense, it is a [[hybrid algorithm]] that combines both merge sort and insertion sort.<ref>{{harvtxt|Knuth|1998}}, p. 184: "Since it involves some aspects of merging and some aspects of insertion, we call it ''merge insertion''."</ref>
For small inputs (up to <math>n=11</math>) its numbers of comparisons equal the [[lower bound]] on comparison sorting of <math>\lceil\log_2 n!\rceil\approx n\log_2 n - 1.443n</math>. However, for larger inputs the number of comparisons made by the merge-
Merge-
Merge insert sort is the sorting algorithm with the fewest possible comparisons for <math>n</math> items whenever <math>n\le 14</math>, and for <math>20\le n\le 22</math>.{{r|pec}}
For 20 years, merge-
However, in 1979 Glenn Manacher published another sorting algorithm that used even fewer comparisons, for large enough inputs.{{r|distrib|nonopt}}
It remains unknown exactly how many comparisons are needed for sorting, for all <math>n</math>, but Manacher's algorithm
and later record-breaking sorting algorithms have all used modifications of the merge-
==References==
|