English

Nearly Tight Bounds for the Online Sorting Problem

Data Structures and Algorithms 2025-08-21 v1

Abstract

In the online sorting problem, a sequence of nn numbers in [0,1][0, 1] (including {0,1}\{0,1\}) have to be inserted in an array of size mnm \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 2lognloglogn+log(1/ε)2^{\sqrt{\log n} \sqrt{\log \log n + \log (1/\varepsilon)}}-competitive algorithm when m=(1+ε)nm = (1+\varepsilon) n for any εΩ(logn/n)\varepsilon \ge \Omega(\log n/n). They also showed a lower bound: with m=γnm = \gamma n space, the competitive ratio of any deterministic algorithm is at least 1γΩ(logn/loglogn)\frac{1}{\gamma}\cdot\Omega(\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(log2n/ε)O(\log^2 n / \varepsilon)-competitive algorithm with m=(1+ε)nm = (1+\varepsilon) n, for any εΩ(logn/n)\varepsilon \ge \Omega(\log n / n). Next, for m=γnm = \gamma n where γ=[O(1),O(log2n)]\gamma = [O(1), O(\log^2 n)], we give a deterministic O(log2n/γ)O(\log^2 n / \gamma)-competitive algorithm. In particular, this implies an O(1)O(1)-competitive algorithm with O(nlog2n)O(n \log^2 n) space, which is within an O(lognloglogn)O(\log n\cdot \log \log n) factor of the lower bound of Ω(nlogn/loglogn)\Omega(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(log2n)O(\log^2 n) on the product of the competitive ratio and γ\gamma while the lower bound on this product is Ω(logn/loglogn)\Omega(\log n / \log\log 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(logn)O(\log n) factor in the competitive ratio.

Keywords

Cite

@article{arxiv.2508.14287,
  title  = {Nearly Tight Bounds for the Online Sorting Problem},
  author = {Yossi Azar and Debmalya Panigrahi and Or Vardi},
  journal= {arXiv preprint arXiv:2508.14287},
  year   = {2025}
}
R2 v1 2026-07-01T04:57:43.120Z