🤖 AI Summary
This paper studies the online sorting problem: sequentially inserting $n$ numbers from $[0,1]$ into an array of size $m geq n$, aiming to minimize the sum of absolute differences between values at adjacent non-empty positions. Prior deterministic algorithms for $m = (1+varepsilon)n$ suffered from an exponential gap between their competitive ratios and the known lower bounds. We present the first near-optimal trade-off between space and competitiveness: a deterministic online algorithm based on block partitioning and dynamic interval management. Using $O(n log^2 n)$ space, it achieves competitive ratios of $O(log^2 n / varepsilon)$ for $m = (1+varepsilon)n$ and $O(log^2 n / gamma)$ for $m = gamma n$, respectively. We provide matching upper and lower bound analyses, nearly resolving the fundamental theoretical bottleneck of this problem.
📝 Abstract
In the online sorting problem, a sequence of $n$ numbers in $[0, 1]$ (including ${0,1}$) have to be inserted in an array of size $m ge n$ so as to minimize the sum of absolute differences between pairs of numbers occupying consecutive non-empty cells. Previously, Aamand {em et al.} (SODA 2023) gave a deterministic $2^{sqrt{log n} sqrt{log log n + log (1/varepsilon)}}$-competitive algorithm when $m = (1+varepsilon) n$ for any $varepsilon ge Ω(log n/n)$. They also showed a lower bound: with $m = γn$ space, the competitive ratio of any deterministic algorithm is at least $frac{1}γcdotΩ(log n / log log n)$. This left an exponential gap between the upper and lower bounds for the problem.
In this paper, we bridge this exponential gap and almost completely resolve the online sorting problem. First, we give a deterministic $O(log^2 n / varepsilon)$-competitive algorithm with $m = (1+varepsilon) n$, for any $varepsilon ge Ω(log n / n)$. Next, for $m = γn$ where $γ= [O(1), O(log^2 n)]$, we give a deterministic $O(log^2 n / γ)$-competitive algorithm. In particular, this implies an $O(1)$-competitive algorithm with $O(n log^2 n)$ space, which is within an $O(log ncdot log log n)$ factor of the lower bound of $Ω(n log n / log log n)$. Combined, the two results imply a close to optimal tradeoff between space and competitive ratio for the entire range of interest: specifically, an upper bound of $O(log^2 n)$ on the product of the competitive ratio and $γ$ while the lower bound on this product is $Ω(log n / loglog n)$. We also show that these results can be extended to the case when the range of the numbers is not known in advance, for an additional $O(log n)$ factor in the competitive ratio.