Skip to content

Average-Case Shellsort: Pass-Comparison Tradeoffs and Deterministic Construction

Wei Pang

cs.CC

Abstract

We study ordinary Shellsort with an input-independent decreasing gap table, charging all key comparisons. Let Ap(n)A_p(n) be its minimum uniform-permutation mean among tables of at most pp passes. We construct an explicitly sampleable distribution showing, for an absolute constant CC and all n≥2n\ge2, p≥1p\ge1, Ap(n)≤Cnp(n3⌈log⁡2(2n)⌉)1/(p+3/2).A_p(n)\le Cnp \bigl(n^3\lceil\log_2(2n)\rceil\bigr)^{1/(p+3/2)}. The construction combines prime gaps that reduce uncertainty on the original random input with a coprime suffix valid for each entrance state. A second-moment interface joins the phases without resampling their intermediate chains. A Frobenius bound pays the final insertion pass. In particular, at p=⌊clog⁡n⌋p=\lfloor c\log n\rfloor the limiting mean coefficient is O(ce3/c)O(ce^{3/c}) for 0<c≤10<c\le1, compared with the classical Ω(ce1/c)Ω(ce^{1/c}) lower bound. We also give a pointwise randomized-table bound 258np n4/(p+1/2)2^{58}np\,n^{4/(p+1/2)} for every fixed input. Separately, we approximate the complete mean of any legal table to additive error one deterministically in exp⁡(n2/3+o(1))\exp(n^{2/3+o(1)}) time and polynomial space. The reduction uses coupled Boolean evaluations and the comparator-circuit pseudorandom generator of Cavalar and Lu. Enumerating our support then deterministically selects a table meeting the mean upper bound, up to additive two, when p=O(log⁡n)p=O(\log n). Our companion manuscript independently establishes unrestricted average order Θ(nlog⁡n)Θ(n\log n) and a subexponential deterministic construction; Du and Wan independently obtain the same optimal average order. The results here refine the pass-dependent bounds and improve the deterministic preprocessing guarantee. They do not determine the optimal general exponent or give a polynomial-time deterministic construction.

Create a lesson

Metadata

Comments
28 pages