Sorting numberIn mathematics and computer science, the sorting numbers are a sequence of numbers introduced in 1950 by Hugo Steinhaus for the analysis of comparison sort algorithms. These numbers give the worst-case number of comparisons used by both binary insertion sort and merge sort. However, there are other algorithms that use fewer comparisons. Formula and examplesThe th sorting number is given by the formula[1] The sequence of numbers given by this formula (starting with ) is The same sequence of numbers can also be obtained from the recurrence relation[2],
It is an example of a 2-regular sequence.[2] Asymptotically, the value of the th sorting number fluctuates between approximately and depending on the ratio between and the nearest power of two.[1] Application to sortingIn 1950, Hugo Steinhaus observed that these numbers count the number of comparisons used by binary insertion sort, and conjectured (incorrectly) that they give the minimum number of comparisons needed to sort items using any comparison sort. The conjecture was disproved in 1959 by L. R. Ford Jr. and Selmer M. Johnson, who found a different sorting algorithm, the Ford–Johnson merge-insertion sort, using fewer comparisons.[1] The same sequence of sorting numbers also gives the worst-case number of comparisons used by merge sort to sort items.[2] Other applicationsThe sorting numbers (shifted by one position) also give the sizes of the shortest possible superpatterns for the layered permutations.[3] References
|