paper

Near-Optimal In-Place Sorting

arXiv:2607.27040

Abstract

We present an in-place comparison-based sorting algorithm that sorts an array of elements using comparisons with exponentially high probability and always moves. This serves as the first in-place sorting algorithm to match the fundamental lower bound on total operations (i.e. sum of comparisons and moves). For the worst-case, we present an algorithm that makes comparisons and data moves, where is an integer parameter satisfying and denotes the -time iterated logarithm, improving over the previous upper bound of comparisons and moves when using constant . When , this yields a worst-case upper bound on total operations of . We thus achieve the ultimate goal of efficient in-place sorting via randomization whilst narrowing the gap to this goal in the worst-case. This advance involves a novel ordered set structure that supports searches in an optimal comparisons for elements. Note that both algorithms are unstable.

arXiv comment33 pages, 2 figures. Appendix starts on page 16. v2: Revised version ported to the LIPIcs template with improved presentation, added figures and stability analysis for the deterministic additional memory algorithm