🤖 AI Summary
This work addresses the problem of achieving comparison-based sorting with near-optimal efficiency under the constraints of using only linear data moves and in-place operations. We propose a novel randomized in-place sorting algorithm that, for the first time, simultaneously achieves an expected $n \lg n + O(n)$ comparisons—matching the information-theoretic lower bound up to an additive linear term—and $O(n)$ data moves. The approach introduces a new ordered set structure supporting optimal searching and employs a parameterized design to balance worst-case overhead: for any integer $t$, it sorts using $n \lg n + O(n \lg^{(t)} n)$ comparisons and $O(tn)$ moves, significantly improving upon the previous best-known bound of $n \lg n + O(n \lg \lg n)$ comparisons.
📝 Abstract
We present the first in-place comparison-based sorting algorithm that sorts an array of $n$ elements using $n\lg n + O(n)$ comparisons with exponentially high probability and always $O(n)$ moves. This matches the information-theoretic lower bound up to an additive linear term despite making only linear moves and working in-place. For the worst-case, we present an algorithm that makes $n\lg n + O(n\lg^{(t)}n)$ comparisons and $O(tn)$ data moves, where $t$ is an integer parameter satisfying $2 \leq t \leq \lg^{*}n - 1$ and $\lg^{(t)}n$ denotes the $t$-time iterated logarithm, improving over the previous upper bound of $n\lg n + O(n\lg\lg n)$ comparisons and $O(n)$ moves when using constant $t>2$. We thus achieve the ultimate goal of minimal move in-place sorting via randomization whilst narrowing the gap to this goal in the worst-case. This advance primarily relies on a novel ordered set structure that supports searches in an optimal $\lg n + O(1)$ comparisons for $n$ elements.