Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Sorting number

From Wikipedia, the free encyclopedia
Worst-case number of comparisons used by sorting algorithms

Inmathematics andcomputer science, thesorting numbers are a sequence of numbers introduced in 1950 byHugo Steinhaus for the analysis ofcomparison sort algorithms. These numbers give theworst-case number of comparisons used by bothbinary insertion sort andmerge sort. However, there are otheralgorithms that use fewer comparisons.

Formula and examples

[edit]

Then{\displaystyle n}th sorting number is given by the formula[1]

nlog2n2log2n+1.{\displaystyle \displaystyle n\lceil \log _{2}n\rceil -2^{\lceil \log _{2}n\rceil }+1.}

The sequence of numbers given by this formula (starting withn=1{\displaystyle n=1}) is

0, 1, 3, 5, 8, 11, 14, 17, 21, 25, 29, 33, 37, 41, ... (sequenceA001855 in theOEIS).

The same sequence of numbers can also be obtained from therecurrence relation[2],

A(n)=A(n/2)+A(n/2)+n1{\displaystyle A(n)=A{\bigl (}\lfloor n/2\rfloor {\bigr )}+A{\bigl (}\lceil n/2\rceil {\bigr )}+n-1}.

It is an example of a2-regular sequence.[2]

Asymptotically, the value of then{\displaystyle n}th sorting number fluctuates between approximatelynlog2nn{\displaystyle n\log _{2}n-n} andnlog2n0.915n,{\displaystyle n\log _{2}n-0.915n,} depending on the ratio betweenn{\displaystyle n} and the nearestpower of two.[1]

Application to sorting

[edit]

In 1950,Hugo Steinhaus observed that these numbers count the number of comparisons used bybinary insertion sort, and conjectured (incorrectly) that they give the minimum number of comparisons needed to sortn{\displaystyle n} items using anycomparison sort. The conjecture was disproved in 1959 byL. R. Ford Jr. andSelmer M. Johnson, who found a different sorting algorithm, the Ford–Johnsonmerge-insertion sort, using fewer comparisons.[1]

The same sequence of sorting numbers also gives theworst-case number of comparisons used bymerge sort to sortn{\displaystyle n} items.[2]

Other applications

[edit]

The sorting numbers (shifted by one position) also give the sizes of the shortest possiblesuperpatterns for thelayered permutations.[3]

References

[edit]
  1. ^abcFord, Lester R. Jr.;Johnson, Selmer M. (1959), "A tournament problem",American Mathematical Monthly,66 (5):387–389,doi:10.2307/2308750,JSTOR 2308750,MR 0103159
  2. ^abcAllouche, Jean-Paul;Shallit, Jeffrey (1992), "The ring ofk{\displaystyle k}-regular sequences",Theoretical Computer Science,98 (2):163–197,doi:10.1016/0304-3975(92)90001-V,MR 1166363. See Example 28, p. 192.
  3. ^Albert, Michael; Engen, Michael; Pantone, Jay; Vatter, Vincent (2018), "Universal layered permutations",Electronic Journal of Combinatorics,25 (3): P23:1–P23:5,arXiv:1710.04240,doi:10.37236/7386,S2CID 52100342
Classes ofnatural numbers
Powers and related numbers
Of the forma × 2b ± 1
Other polynomial numbers
Recursively defined numbers
Possessing a specific set of other numbers
Expressible via specific sums
2-dimensional
centered
non-centered
3-dimensional
centered
non-centered
pyramidal
4-dimensional
non-centered
Combinatorial numbers
Divisor functions
Prime omega functions
Euler's totient function
Aliquot sequences
Primorial
Otherprime factor ordivisor related numbers
Numeral system-dependent numbers
Arithmetic functions
anddynamics
Digit sum
Digit product
Coding-related
Other
P-adic numbers-related
Digit-composition related
Digit-permutation related
Divisor-related
Other
Generated via asieve
Sorting related
Graphemics related
Retrieved from "https://en.wikipedia.org/w/index.php?title=Sorting_number&oldid=1328064441"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp