---
title: Sorting with Persistent Comparison Errors
url: https://www.emergentmind.com/topics/sorting-with-persistent-comparison-errors
type: topic
---

# Sorting with Persistent Comparison Errors

Searching arXiv for recent and foundational papers on persistent comparison errors in sorting.
Sorting with persistent comparison errors studies comparison-based ordering when the response associated with a pair of elements is not freshly randomized at each query. Instead, once the comparator induces an outcome for a pair, repeating the same comparison yields the same answer. In the Braverman–Mossel setting, each pairwise comparison is wrong with fixed probability \(p\) and then remains fixed; in learning-augmented variants, a fast but unreliable comparator induces a fixed tournament that may disagree with the true order; and in adversarial formulations, sufficiently close items or comparisons incident to a bad set may be answered arbitrarily [1804.07575] [1709.07249] [2311.00749] [2310.09483] [2502.07653]. Across these formulations, exact sorting is either impossible or no longer the operative objective, and the focus shifts to approximate orders with controlled dislocation, to approximation guarantees that respect an ambiguity radius, or to minimizing the number of expensive exact comparisons.

## 1. Model families and the meaning of persistence

The defining feature of persistence is that repeated queries on the same pair do not provide independent evidence. In the recurrent random model, the input consists of \(n\) distinct elements, each pairwise comparison is wrong with fixed probability \(p\), errors are independent across pairs, and once the comparison outcome for a pair \((x,y)\) is determined, repeating that comparison later always yields the same outcome [1709.07249]. The 2018 optimal-sorting formulation states the same basic regime as the persistent comparison error model introduced by Braverman and Mossel: every comparison between two elements is independently wrong with fixed probability \(p\), and comparisons cannot be repeated in any useful way because the outcome for a pair is persistent [1804.07575].

A second family replaces probabilistic recurrent errors by a fixed flawed comparator. In the dirty-versus-clean model, the algorithm receives a clean comparator \(<\), which is exact but expensive, and a dirty comparator, which is fast but may be wrong. For any distinct \(a_i,a_j\), the dirty relation induces exactly one directed edge, so it forms a tournament rather than a total order, and it need not be transitive, so cycles can occur. This directly models persistent comparison errors as a fixed incorrect predictor of the true order [2311.00749].

A third family strengthens the adversarial aspect. In the adversarial comparator model, if \(|x_i-x_j|>1\), then the comparator must return the correct order, while if \(|x_i-x_j|\le 1\), the answer may be arbitrary and can depend on the full history of previous queries; the objective becomes \(k\)-approximate sorting or selection rather than exact recovery [2310.09483]. In the robust-sorting tournament model, a tournament \(G=(V,E)\) is \(B\)-imperfect with respect to a hidden order \(\pi\) if every comparison between two good nodes \(u,v\in V\setminus B\) is correct with respect to \(\pi\), while any comparison involving at least one node in \(B\) can be arbitrary [2502.07653].

| Model | Persistence mechanism | Primary objective |
|---|---|---|
| Recurrent random errors | Each pair is wrong with fixed probability \(p\), and repetitions return the same outcome | Minimize maximum and total dislocation [1709.07249] |
| Dirty and clean comparisons | Dirty comparator is a fixed possibly cyclic tournament; clean comparator is exact and expensive | Minimize clean comparisons [2311.00749] |
| Adversarial comparator | Close pairs may be answered arbitrarily, possibly adaptively | \(k\)-approximate sorting/selection [2310.09483] |
| \(B\)-imperfect tournament | Edges incident to bad nodes may be arbitrary | Maximize agreement with hidden order [2502.07653] |

A common misconception is to treat these settings as ordinary noisy sorting with resampling. That is inaccurate. In the persistent regime, repeated comparison does not attenuate error by majority vote, because the same pairwise edge reappears unchanged. This distinction drives both the impossibility results and the algorithm design.

## 2. Quality criteria and error measures

The standard quality notion in persistent-error sorting is dislocation. If \(x\) has true rank \(x\) and appears at position \(\sigma(x)\) in the output permutation, then its dislocation is
\[
|\sigma(x)-x|.
\]
The maximum dislocation is
\[
\max_x |\sigma(x)-x|,
\]
and the total dislocation is
\[
\sum_x |\sigma(x)-x|.
\]
Equivalent formulations use \(\rank(x,S)\), \(\pos(x,S)\), and
\[
\disl(x,S)=|\pos(x,S)-\rank(x,S)|.
\]
These measures are central in the Braverman–Mossel line of work and in subsequent \(O(n^2)\)- and \(O(n\log n)\)-time algorithms [1709.07249] [1804.07575].

The dirty-comparison model uses a different, explicitly local error measure. For each item,
\[
\eta_i := \left|\{j \in [n]\colon (a_i < a_j) \ne (a_i a_j) \}\right|.
\]
Thus \(\eta_i\) counts how many dirty comparisons incident to \(a_i\) disagree with the true order. This is an element-wise error measure rather than a global count of bad pairs. If one introduces a global error measure \(D\), then Jensen’s inequality gives
\[
O\!\left(\sum_i \log(\eta_i+2)\right) \le O\!\left(n\log\left(\frac{D}{n}+2\right)\right),
\]
and for dirty comparisons \(D=\frac12\sum_i \eta_i\) [2311.00749].

Adversarial formulations replace dislocation by approximation with respect to an ambiguity radius. The definition \(x_i \ge_k x_j\) means \(x_i \ge x_j-k\). A \(k\)-approximate sorting is one in which every inversion involves elements differing by at most \(k\), and a \(k\)-approximate \(i\)-selection is one where the returned item can appear as the \(i\)-th item of some \(k\)-approximate sorting. The paper proves the equivalence
\[
x_j \text{ is a } k\text{-approximate } i\text{-selection} \quad\Longleftrightarrow\quad |x_j-x_i|\le k,
\]
where \(x_i\) is the true \(i\)-th smallest element [2310.09483].

The robust-sorting tournament model measures output quality by common subsequence length. If \(\pi'\) is the returned ordering and \(\pi\) the hidden truth, the target is to maximize \((\pi,\pi')\), and the main guarantee is
\[
\mathbb{E}[(\pi,\pi')] \ge n - (3+\epsilon)|B|.
\]
This metric is tailored to a setting in which only a bounded set of vertices can corrupt pairwise outcomes [2502.07653].

These definitions reflect a broader shift in objective. Because perfect sorting is impossible in the persistent-error model, the natural goal is not exact recovery but the strongest achievable structural approximation under the available comparator semantics.

## 3. Approximate sorting algorithms under recurrent random errors

A basic algorithmic milestone is **Window Sort**, designed for recurrent random comparison errors. It starts with window \(w=n/2\); in each iteration, every element compares only against its \(2w\) left neighbors and \(2w\) right neighbors in the current permutation, computes a local score, reorders by the resulting computed ranks, and then halves the window size until \(w<1\). If \(x\) is currently at position \(l=\sigma(x)\), then its computed rank is
\[
\max\{l-2w,0\} + wins(x),
\]
where \(wins(x)\) is the number of local comparisons where \(x\) is reported larger than the other element. The algorithm runs in \(O(n^2)\) time, since an iteration with window \(w\) does \(O(nw)\) work and the geometric sum over halving windows is \(O(n^2)\) [1709.07249].

The analysis is controlled by local error sets. For an element \(x\) and window size \(w\), \(ERRORS(x,w)\) is the set of errors among comparisons between \(x\) and every \(y\in [x-4w,x+4w]\). If for all elements \(x\) and for all window sizes \(w=n/2,n/4,\ldots,2w^\star\),
\[
|ERRORS(x,w)|\le w/4,
\]
then Window Sort returns a sequence whose maximum dislocation is at most
\[
9w^\star.
\]
From Chernoff bounds and a union bound, the paper derives that with probability at least \(1-1/n\), Window Sort has maximum dislocation at most
\[
9\cdot f(p)\cdot \log n,
\]
where
\[
f(p) =
\begin{cases}
\frac{400p}{(1-32p)^2} & \text{for } 1/64 < p < 1/32,\\[4pt]
\frac{4}{\ln \left(\frac{1}{32p}\right)-\left(1-32p\right)} & \text{for } 1/192 < p \le 1/64,\\[4pt]
6 & \text{for } p \le 1/192.
\end{cases}
\]
Its expected total dislocation is at most
\[
n \cdot 60\, f(p)\log f(p).
\]
The paper also gives a slower window-shrinking variant \(w\leftarrow \alpha w\), with runtime
\[
O\!\left(\frac{1}{1-\alpha}n^2\right),
\]
valid for \(p<\alpha/16\) [1709.07249].

A subsequent line of work shows that these dislocation guarantees can be achieved in optimal comparison time. The 2018 paper on optimal sorting under persistent comparison errors presents the first randomized \(O(n\log n)\)-time algorithm with \(O(\log n)\) maximum dislocation and \(O(n)\) total dislocation with high probability. Its structure rests on two subproblems: inserting one element into an almost-sorted sequence while preserving \(O(\log n)\)-scale dislocation, and simultaneously inserting \(m\) elements into an almost-sorted sequence of \(m\) elements so that the resulting \(2m\)-element sequence remains almost sorted. The key rank-estimation primitive is a noisy binary search that, if \(S\) has maximum dislocation at most \(d\ge \log n\), finds an approximate insertion position \(r_x\) satisfying
\[
|r_x-\rank(x,S)|=O(\max\{d,\log n\})
\]
in \(O(\log n)\) time with probability at least \(1-O(n^{-6})\). The full **RiffleSort** algorithm randomly partitions the input into batches \(T_0,T_1,\dots,T_k\), approximately sorts \(T_0\) using WindowSort, then alternates merge steps based on approximate ranks and repair steps using WindowSort [1804.07575].

The 2025 paper on persistent random comparison faults rephrases the same high-level architecture in terms of **NoisySearch** and **BasketSort**. For constants \(0\le q\le p < \frac{9q+1}{8q+11}\), and in particular for the special case \(p=q<1/4\), it states that randomized **RiffleSort** runs in
\[
O(n\log n)
\]
worst-case time and returns a permutation with maximum dislocation \(O(\log n)\) and total dislocation \(O(n)\) with high probability. NoisySearch takes an approximately sorted sequence \(S\) of size \(m\) with maximum dislocation at most \(d\), and returns an index \(\tau_x\) in
\[
[\rank(x,S)-\alpha d,\ \rank(x,S)+\alpha d]
\]
in \(O(\log m)\) time with probability at least \(1-O(m^{-6})\). BasketSort takes a sequence \(S\) with an upper bound \(w_S\ge \disl(S)\), runs in
\[
O(mw_S)
\]
time, and outputs a sequence with maximum dislocation \(O(\log m)\) and total dislocation \(O(m)\) with high probability [2508.19785].

Taken together, these results establish a progression from quadratic-time multiscale local repair to \(O(n\log n)\)-time approximate sorting with asymptotically optimal dislocation guarantees.

## 4. Dirty comparators, clean repair, and learning-augmented sorting

The dirty-versus-clean model isolates a distinct persistent-error scenario: a cheap predictor is fixed and potentially wrong, while a second comparator is exact but expensive. Formally, the dirty relation induces exactly one directed edge on each distinct pair, hence a tournament, and it may contain cycles. The per-item disagreement count is
\[
\eta_i := \left|\{j \in [n]\colon (a_i < a_j) \ne (a_i a_j) \}\right|.
\]
The central theorem states that there is a randomized algorithm that sorts within \(O(n\log n)\) running time, \(O(n\log n)\) dirty queries, and
\[
O\!\left(\sum_{i=1}^{n}\log(\eta_i+2)\right)
\]
clean comparisons in expectation. A matching lower bound shows that no sorting algorithm can use
\[
o\!\left(\sum_{i=1}^{n}\log(\eta_i+2)\right)
\]
clean comparisons [2311.00749].

The algorithmic idea is randomized incremental BST insertion. Items are processed in uniformly random order. Each new item first follows a dirty search path in the current BST, while maintaining boundary values \(L_t,R_t\) that delimit where the item could still fit. When the dirty path reaches a nil leaf, the algorithm backtracks to the last valid step \(t^\*\) such that \(L_{t^\*}<a_i<R_{t^\*}\), and then resumes with clean comparisons from that point. The dirty phase is therefore used only as guidance; the clean phase verifies and repairs precisely the part of the path where the dirty comparator became inconsistent with the true order.

The analysis hinges on two facts. First, the random insertion order makes the BST balanced enough in expectation, yielding \(E[T]=O(\log n)\) for the dirty-search length \(T\). Second, the clean correction is governed by \(\eta_i\). If the active subtree size at step \(t\) satisfies \(s_t\in(2^{k-1},2^k]\), then
\[
P\!\left[t=t^* \mid s_t\in(2^{k-1},2^k]\right] \le \frac{\eta_i}{2^{k-1}}.
\]
From this, the paper derives
\[
E[\log(s_{t^*})] = O(\log(\eta_i+1)),
\]
and therefore the clean search for item \(a_i\) uses expected length
\[
O(\log(\eta_i+1)).
\]
Summing over the items yields the overall
\[
O\!\left(\sum_i \log(\eta_i+2)\right)
\]
clean-comparison bound [2311.00749].

A notable feature is smooth degradation. If every \(\eta_i\) is small, then \(\log(\eta_i+2)=O(1)\) per item and the clean comparison complexity is \(O(n)\). If the predictor is poor and \(\eta_i\) can be as large as \(\Theta(n)\), then
\[
\sum_i \log(\eta_i+2)=\Theta(n\log n),
\]
matching classical comparison sorting. The same paper also treats multiple dirty predictors: if predictor \(p\) has per-item errors \(\eta_i^p\), then there is a randomized algorithm using
\[
O\!\left(\min_p \sum_{i=1}^n \log(\eta_i^p+2)\right)
\]
clean comparisons, via a reduction to prediction with expert advice using Hedge [2311.00749].

This framework differs sharply from recurrent random errors. It does not attempt to average away uncertainty by repeated dirty queries. Instead, it exploits the structure of a fixed flawed predictor and pays exact-comparison cost only where local inconsistency forces repair.

## 5. Lower bounds and impossibility phenomena

Persistent comparison errors impose strong information-theoretic limits. In the recurrent random model, no randomized algorithm can achieve maximum dislocation \(o(\log n)\) with high probability, and no randomized algorithm can achieve expected total dislocation \(o(n)\), regardless of running time. One proof route uses a pairwise inversion lemma: for any randomized algorithm \(A\) and any \(x<y\), the probability that \(A\) outputs \(x\) and \(y\) in the wrong relative order is at least
\[
\frac{1}{2}\left(\frac{p}{1-p}\right)^{2(y-x)-1}.
\]
From this, choosing pairs at distance \(\Theta(\log n)\) yields the \(\Omega(\log n)\) maximum-dislocation barrier, and considering disjoint adjacent pairs yields the \(\Omega(n)\) expected total-dislocation barrier [1709.07249].

The optimal-sorting papers sharpen the computational side of the barrier. They state that if one could guarantee \(O(\log n)\) maximum dislocation in \(o(n\log n)\) time under persistent errors, then one would obtain an \(o(n\log n)\)-time exact sorting algorithm even without errors, contradicting the classical lower bound for comparison sorting. Accordingly, \(\Omega(n\log n)\) time is necessary for \(O(\log n)\)-scale maximum dislocation, while \(O(\log n)\) maximum dislocation and \(O(n)\) total dislocation are asymptotically optimal targets [1804.07575] [2508.19785].

The dirty-comparison setting has an analogous lower bound, but indexed by local prediction error rather than by dislocation. No sorting algorithm can use
\[
o\!\left(\sum_i \log(\eta_i+2)\right)
\]
clean comparisons. The lower-bound argument is information-theoretic: if too few clean comparisons are made, the algorithm cannot distinguish among the many permutations consistent with the dirty comparator and the error budget [2311.00749].

Adversarial comparison models introduce further impossibility phenomena. In the threshold-\(1\) adversarial comparator model, no algorithm can do better than a factor-\(2\) approximation in general, because adversarial comparisons can make a cluster of nearby values indistinguishable. The same paper cites the Ajtai–Feldman–Hassidim–Nelson lower bound
\[
\Omega\!\left(n^{1+1/2^{k-1}}\right)
\]
for deterministic \(k\)-approximate sorting and selection, while randomized algorithms achieve polylogarithmic overhead over linear-time baselines [2310.09483].

Related lower bounds appear in downstream problems. For longest increasing subsequence under persistent comparison errors, the achievable approximation factor is asymptotically limited: there exists a distribution over instances on which no algorithm can guarantee better than an \(\Omega(\log n)\) approximation with high probability, and any \(O(\log n)\)-approximation algorithm requires \(\Omega(n\log n)\) comparisons even in the absence of errors [1808.03307].

These lower bounds show that persistent errors do not merely perturb classical sorting. They change the optimization target and define a new frontier where logarithmic maximum displacement, linear total displacement, or logarithmic clean-comparison dependence on local error become the natural optimum.

## 6. Related formulations, structural insights, and applications

Several adjacent areas refine the structural picture of persistence. In the energy-based noisy comparator model, comparison outcomes are randomized with bias determined by \(\lambda\) and by a weight \(w\), through probabilities of the form
\[
\frac{\lambda^w}{\lambda^w+\lambda^{-w}}.
\]
The sorting process is modeled as a finite Markov chain on permutations, and the paper shows that repeatedly comparing adjacent elements can be better than comparing arbitrary pairs: for three elements, the stationary ratios include
\[
\frac{\pi_{\text{adj}(123)}}{\pi_{\text{adj}(321)}} = \lambda^8,\qquad
\frac{\pi_{\text{adj}(123)}}{\pi_{\text{adj}(213)}} = \lambda^2,\qquad
\frac{\pi_{\text{adj}(123)}}{\pi_{\text{adj}(231)}} = \lambda^6.
\]
The conclusion is about long-run behavior: local adjacent-comparison dynamics can concentrate more stationary mass on the correctly sorted permutation than more global noisy dynamics [1610.09223].

A related Markovian viewpoint appears in swap-based noisy sorting. In \(SwapSort_{p,r}\), a random pair of positions at distance at most \(r\) is compared, the comparison is wrong with probability \(p<1/2\), and a swap is performed if the noisy comparison declares the pair out of order. For \(r=1\), the chain is reversible and the stationary distribution satisfies
\[
q(s')=\frac{1}{Z}\cdot\left(\frac{p}{1-p}\right)^{I(s')},
\]
where \(I(s')\) is the inversion count. The paper proves that, with high probability for \(\pi\sim S^\infty_{p,1}\),
\[
I(\pi)\leq W(\pi)=O(n\log n),
\qquad
\max_{1\leq i\leq n}|i-\pi(i)|=O(\log n),
\]
and that the convergence-time proxies \({}^{I}(\epsilon)\) and \({}^{W}(\epsilon)\) are both \(\Theta(n^2)\). For \(r=n\), the chain is non-reversible and stationary quality is much worse, with
\[
\frac{p(n^2-1)}{6} \leq E(D(S^{\infty}_{p,n})) \leq O(p^{1/3}n^2),
\]
and
\[
\frac{pn^3}{648} \leq E(W(S^{\infty}_{p,n})) \leq O(p^{1/2}n^3).
\]
This yields a clear trade-off between faster convergence for larger \(r\) and better stationary quality for smaller \(r\) [1803.04509].

Persistent-error sorting also functions as a subroutine in other problems. For LIS under persistent comparison errors, approximate sorting with low maximum dislocation is the key bridge. If an approximate order \(apx\) satisfies \(\disl(apx)\le d\), then every pair of elements separated by at least \(2d\) positions in \(apx\) appears in the correct relative order in the true sorted order, and the longest \(2d\)-distant subsequence \(S^\*\) satisfies
\[
|S^*| \ge \frac{1}{2d}|LIS(S)|.
\]
Using an \(O(n\log n)\)-time approximate sorting algorithm with maximum dislocation \(O(\log n)\), the paper obtains an \(O(\log n)\)-approximation to LIS in \(O(n\log n)\) time with probability at least \(1-\frac1n\) [1808.03307].

Robust sorting in a \(B\)-imperfect tournament yields a different application profile. The robust-sorting paper gives a randomized algorithm that queries
\[
O\!\left(\frac{n\log^3 n}{\epsilon^2}\right)
\]
edges and outputs \(\pi'\) such that
\[
\mathbb{E}[(\pi,\pi')] \ge n-(3+\epsilon)|B|.
\]
Its quick-sort-like recursion uses triangle detection, sampled balance tests, and a triangle-versus-concatenation-loss bound. The same framework leads to the first \((2-\varepsilon)\) FPT linear-time approximation algorithm for Ulam-\(k\)-Median, with runtime
\[
\tilde{O}(nd\cdot k^k)
\]
and approximation factor \(2-\delta''\) with probability at least \(0.99\) [2502.07653].

The broader significance of these results is methodological rather than merely technical. Persistent comparison errors force algorithms to work with structure—local neighborhoods, nearly sorted intermediates, error-sensitive repairs, tournament geometry, and concentration in stationary distributions—because repetition alone does not create new information. This suggests that the central organizing principle of the area is not noise reduction by redundancy, but approximation under irrevocable comparator bias.

Source: https://www.emergentmind.com/topics/sorting-with-persistent-comparison-errors