In 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.
The
n
n=1
The same sequence of numbers can also be obtained from the recurrence relation,
A(n)=Al(\lfloorn/2\rfloorr)+Al(\lceiln/2\rceilr)+n-1
It is an example of a 2-regular sequence.
Asymptotically, the value of the
n
nlog2n-n
nlog2n-0.915n,
n
In 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
n
The same sequence of sorting numbers also gives the worst-case number of comparisons used by merge sort to sort
n
The sorting numbers (shifted by one position) also give the sizes of the shortest possible superpatterns for the layered permutations.