arXiv · 2612.00043
Tight Comparison Bounds for Stable Sorting with Predicted Repetitions and Bounded Lookahead
Abstract
With a strict comparator, verifying $x=y$ takes two comparisons. We study stable sorting under prefix deadlines: the order of the first $i$ records must be determined before any record beyond position $i+L$ is compared. An untrusted schedule predicts, for each later record, which of the first $q$ records shares its key. Even with correct predictions, schedules with equal label frequencies can require $n+o(n)$ or $2n-o(n)$ comparisons. A packing quantity explains this gap: for each label $c$, let $P_c$ be the largest number of its predicted positions pairwise more than $L$ apart. With at most $e$ wrong predictions and $Q=q+e$, the optimal worst-case comparison count is $n-1+\log_2(Q!)+\sum_c P_c-\mathbf{1}_{e=0}\min_c P_c+O(Q)$ for every schedule and lookahead $L$. The lower bound counts deadline-forced cycles in the comparison graph. The algorithm verifies all predicted equalities except for the largest key, whose records it only checks to be nondecreasing; one early new maximum cancels this saving. Without a schedule, a sorter can learn a repeated permutation from the keys; at zero lookahead, one new maximum raises its leading coefficient from $2-1/q$ to $2$. If each key's successor is predicted from its previous occurrence with $E$ mistakes, lookahead $\lceil\sqrt n\,\rceil$ suffices for $n+o(n)$ comparisons when $q(E+1)=o(n)$, while $o(\sqrt n)$ forces $2n-o(n)$. On two 32,768-record inputs, our implementation is within 3 and 7 comparisons of the optimum.
Explore related subjects
Keep this discovery
Explore connections, maps & timelines
Shunqi Lu. 2026-11-27. Tight Comparison Bounds for Stable Sorting with Predicted Repetitions and Bounded Lookahead. https://searcharxiv.org/abs/2612.00043
Citations retain the original authors and DOI and include this site’s record URL. If this discovery service contributed to your research, you can also cite Search arXiv by Indiciae: BibTeX · RIS.