An Optimal Sorting Algorithm for Persistent Random Comparison Faults

Barbara Geissmann, Stefano Leucci, Chih-Hung Liu, Paolo PennaarXiv 2025 · DOI

Abstract

This paper introduces RiffleSort, the first sorting algorithm for the "persistent random fault" model that is simultaneously optimal in terms of runtime, maximum element displacement, and total error. In this model, comparison errors are permanent and cannot be mitigated by resampling. RiffleSort achieves an $O(n \log n)$ runtime while maintaining a maximum dislocation of $O(\log n)$, matching the theoretical lower bounds for accuracy in the presence of persistent noise.

Introduction: The Challenge of Persistent Faults

In classical sorting theory, comparisons are assumed to be perfectly reliable. In "noisy" sorting models, a comparison might return an incorrect result with some probability $p$, but reliability can typically be improved by repeating the comparison and taking a majority vote.

This work addresses a significantly more difficult scenario: Persistent Random Comparison Faults. In this model, if a comparison between elements $A$ and $B$ is erroneous, it remains erroneous every time that specific pair is compared. This persistence makes perfect sorting impossible. Instead, the objective is to minimize dislocation—the distance between an element's final position and its true rank. Previous approaches to this problem were either computationally expensive (quadratic time) or failed to provide tight bounds on maximum dislocation.

The RiffleSort Algorithm

RiffleSort is a hybrid algorithm that integrates elements of Insertion Sort and Merge Sort, enhanced by two specialized sub-routines designed to navigate persistent errors:

  1. NoisySearch: To insert elements into an existing sequence, the algorithm performs a random walk on a "noisy binary search tree." To bypass the persistence of errors, it employs a "proxy" strategy: rather than comparing a target element directly against a node, it compares it against the node's neighbors. These neighbors provide independent evidence of the node's true rank.
  2. BasketSort: This serves as a periodic "cleanup" phase. The sequence is partitioned into "baskets" (windows) based on current dislocation estimates. The algorithm iteratively re-orders elements by comparing them against neighboring baskets, effectively shrinking the dislocation until it reaches the $O(\log n)$ threshold.

By processing elements in batches and using BasketSort to "reset" dislocation at each doubling of the sequence size, RiffleSort maintains high accuracy throughout its execution.

Key Results and Theoretical Bounds

The primary contribution of this work is the achievement of asymptotic optimality across all major metrics. As shown in the comparison below, RiffleSort (referred to as "this work") is the first to achieve $O(n \log n)$ time complexity while maintaining the best possible dislocation bounds.

Comparison of RiffleSort with prior work in terms of time complexity and dislocation bounds.

Performance Summary:

  • Optimal Runtime: RiffleSort runs in $O(n \log n)$ time, matching standard noiseless sorting algorithms.
  • Optimal Accuracy: It guarantees a maximum dislocation of $O(\log n)$ and a total dislocation of $O(n)$ with high probability (w.h.p.).
  • Information-Theoretic Limits: The authors prove that $O(\log n)$ maximum dislocation is the absolute lower bound for any algorithm in this model; thus, RiffleSort is asymptotically perfect.
  • Error Tolerance: The algorithm is robust for any constant error probability $p < 1/4$.

Insights and Future Directions

A central insight of this research is the Proxy Principle: while direct comparisons are unreliable and persistent, the "almost-sorted" nature of the intermediate lists allows the algorithm to use nearby elements as independent witnesses. This effectively simulates resampling without ever comparing the same pair twice.

Despite its optimality, some open questions remain. The current analysis requires $p < 0.25$, whereas non-persistent models can handle $p < 0.5$. Additionally, while the big-O complexity is optimal, the constant factors involved in the "basket" sizes may be large, suggesting that future work could focus on practical parameter tuning and exploring adversarial (rather than random) fault models.

Summary updated

BibTeX
@misc{geissmann2025optimal,
  author = {Barbara Geissmann and Stefano Leucci and Chih-Hung Liu and Paolo Penna},
  title = {{An Optimal Sorting Algorithm for Persistent Random Comparison Faults}},
  year = {2025},
  eprint = {2508.19785},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.19785},
}
Figure