Abstract. Sorting creates structure that makes subsequent search cheaper. We study this connection using the squared rank-displacement potential from the permutohedral view of sorting. Given a potential budget \(E\), the optimal worst-case comparison-search cost is \(\Theta(\log n+\min\{n,\sqrt E\})\). A matching lower bound explains the square root: a target can hide among \(r\) positions while using only \(\Theta(r^2)\) potential. We then construct two promised input families with identical maximum potential but different optimal search costs. A potential balance accounts exactly for disorder removed; the arrangement of the remaining disorder determines whether search can improve on the guarantee obtained from the scalar budget alone.
Historical orientation. The argument below joins three older questions. Rank statistics and the geometry of permutations ask how to measure distance from order. Classical comparison algorithms ask how ordering permits logarithmic search and what information sorting comparisons must uncover. Adaptive algorithms ask what can be done when some order is already present. We follow these threads through the potential-based search bound, then return to their common limitation: a single number records the magnitude of disorder but not where it lies.
From preprocessing to usable structure
An unordered array can require \(n\) comparisons to search. Once sorted, it supports binary search in \(\Theta(\log n)\) comparisons. Producing that order by comparison sorting requires \(\Theta(n\log n)\) comparisons in the unrestricted worst case. These bounds suggest an accounting question: how does the structure created during preprocessing translate into the work saved afterward?
Actual effort cannot itself be the conserved quantity. Two sorting procedures can spend very different amounts of work and produce the same array. Existing order also matters: an almost-sorted input may need little additional rearrangement. We therefore account for remaining disorder, rather than identify all work spent with useful progress. The potential in Landers [12] supplies a geometric measure. Our aim is to connect that measure to search complexity, then determine what its scalar value leaves out.
The classical gap between sorting and searching.
Knuth’s treatment of sorting and searching [4] places the two endpoints of this question in a common algorithmic setting: without order, a search may need to examine every entry; with total order, binary search discards a constant fraction of the remaining possibilities at each comparison. The familiar comparison-sorting lower bound counts the possible input orders. Fredman’s treatment of sorting under prior information [5] makes the next historical step: a promise narrows the set of possible orders, so the complexity depends on what the algorithm is told before making comparisons. Here the promise is deliberately sparse—one bound on residual disorder—and the question is how much search power it carries.
Model and geometric potential
Let \(A=(a_1,\ldots,a_n)\) contain \(n\geq2\) distinct keys from an arbitrary totally ordered universe. Put \(x_i=\operatorname{rank}_A(a_i)\) and \(v_s=(1,\ldots,n)\). The rank word \(x\) is a vertex of the permutohedron \(\operatorname{conv}\{\pi(v_s):\pi\in S_n\}\). Define \[V(A)=\frac12\|x-v_s\|_2^2=\frac12\sum_{i=1}^n(x_i-i)^2, \qquad d(A)=\max_i|x_i-i|. \tag{1}\] Thus \(V\) measures squared Euclidean distance to the sorted vertex; it is not the adjacent-swap graph distance. The ranks are an analytical description, not an oracle available to the search algorithm.
The statistical and geometric ancestry of \(V\).
Spearman’s early work on rank correlation [1] made differences between rankings into a quantitative object. For distinct ranks, the usual Spearman coefficient relative to sorted order is \[\rho_s=1-\frac{6\sum_i(x_i-i)^2}{n(n^2-1)} =1-\frac{12V(A)}{n(n^2-1)}. \tag{2}\]
Thus the potential used here is an unnormalized quadratic rank difference. It should be distinguished from Spearman’s footrule, the sum of absolute rank differences, and from Kendall’s discordant-pair measure [2]. Diaconis and Graham [6] related footrule distance to inversion distance, illustrating both the usefulness and the nonidentity of these notions of disarray. Mannila’s theory of presortedness [7] subsequently made the choice of disorder measure part of algorithm design: different measures support different adaptive guarantees. This note chooses the quadratic measure because it connects Landers’s sorting potential to a sharp search guarantee.
The rank word also has a geometric home. Rado’s work on convex hulls of permutations [3] underlies the permutohedral viewpoint: the \(n!\) possible rank words are vertices of one polytope. Landers’s work, first posted in 2025 and revised in 2026 [12], uses that picture to distinguish motion along adjacent-swap edges from an ambient gradient flow and from comparisons that eliminate feasible orders. The search algorithm below does not traverse the polytope; it uses a numerical consequence of distance to one distinguished vertex.
A deterministic search algorithm queries indices \(i\), receiving the outcome of \(y<a_i\), \(y=a_i\), or \(y>a_i\). It must return the index of \(y\), or report absence. There is no auxiliary index or preprocessing transcript. A numerical promise \(V(A)\leq E\) is supplied; obtaining that promise is a separate preprocessing cost. With \(C_S(A,y;E)\) denoting the number of queries, define \[Q^*(n,E)=\inf_{S\ \mathrm{correct}}\ \sup_{A:\,V(A)\leq E}\ \sup_y C_S(A,y;E). \tag{3}\] All logarithms in complexity expressions are base \(2\); constants are independent of \(n,E\).
The promise in (3) should be read in Fredman’s informational spirit [5]: it is knowledge supplied to the algorithm, not a free ability to inspect ranks. In particular, the absence of an auxiliary index or preprocessing transcript prevents the searcher from using location information that may have been available while the array was prepared.
How potential limits displacement
Lemma 1. For every rank word, \(V(A)\geq d(A)(d(A)+1)/2\). Consequently, if \(V(A)\leq E\), then \[d(A)\leq D_E:=\min\left\{n-1,\left\lfloor\frac{\sqrt{1+8E}-1}{2}\right\rfloor\right\}. \tag{4}\]
Proof. Set \(\delta_i=x_i-i\) and select \(j\) with \(|\delta_j|=d\). Since \(\sum_i\delta_i=0\), \(\sum_{i\ne j}|\delta_i|\geq d\). Integer displacements satisfy \(\delta_i^2\geq|\delta_i|\), so \(2V=d^2+\sum_{i\ne j}\delta_i^2\geq d^2+d\). Solving this inequality gives (4). ◻
A bridge between global and local disorder.
The lemma converts a global, quadratic budget into a bound on the worst individual displacement. Its proof needs more than the trivial observation \(V\geq d^2/2\): since a rank word is a permutation, a displacement of size \(d\) must be balanced by at least \(d\) units of displacement elsewhere. The resulting \(d(d+1)/2\) is attained when one element moves past \(d\) neighbors. This extremal pattern will reappear in the search lower bound, linking the geometry of the potential to the information available from index queries.
A tight search bound from potential alone
The direct algorithmic predecessor is the study of search in nearly sorted arrays. Disser and Kratsch [9] analyze, among other measures, maximum displacement from sorted position. Their work shows why a binary-search-like phase can remain useful when each item is known to lie near its true rank, and why a residual local scan is necessary. Lemma Lemma 1 translates the present potential promise into precisely that kind of displacement certificate. The theorem then states the minimax consequence for this note’s model, including absent targets and a promise expressed only as \(V\leq E\).
Theorem 2. For \(n\geq2\) and \(E\geq0\), the model in Section 2 satisfies \[\boxed{Q^*(n,E)=\Theta\!\left(\log n+\min\{n,\sqrt E\}\right).} \tag{5}\]
Proof. Upper bound. Suppose first that \(d(A)\leq D\) is known. Maintain an interval \([L,H]\) that contains the target whenever it is present. If its length exceeds \(8D+4\), query \(m=\lfloor(L+H)/2\rfloor\). Return \(m\) on equality. Otherwise update \[\begin{aligned} a_m<y &: \quad L\leftarrow\max\{L,m-2D+1\},\\ a_m>y &: \quad H\leftarrow\min\{H,m+2D-1\}. \end{aligned} \tag{6}\] Once the interval has length at most \(8D+4\), scan it and return the target’s index, or report absence.
To prove the updates safe, suppose \(y=a_p\) and let \(r=x_p\) be its rank. If \(a_m<y\), then \[p\geq r-D\geq x_m+1-D\geq m-2D+1. \tag{7}\] If \(a_m>y\), similarly \(p\leq r+D\leq x_m-1+D\leq m+2D-1\). Thus the target is never discarded. If absent, no equality is returned, and the final scan correctly reports absence.
For interval length \(N\), either update leaves at most \(\lfloor N/2\rfloor+2D\) candidates. When \(N>8D+4\), this is less than \(3N/4\). There are therefore \(O(\log n)\) midpoint queries, followed by \(O(\min\{n,D+1\})\) scan queries. Taking \(D=D_E\leq\sqrt{2E}\) proves the upper bound in (5). This is a direct potential-based formulation of bounded-displacement search [9].
Lower bound. Fix ordered keys \(a_1<\cdots<a_n\) and a target \(y<a_1\). Let \(A^{(0)}=(a_1,\ldots,a_n)\), in which \(y\) is absent. For each \(j\), let \(A^{(j)}\) be the same array with entry \(j\) replaced by \(y\). Its rank word is For \(j=1\) the first segment is empty and the rank word is the identity. Set \[r_E=\min\left\{n,\left\lfloor\frac{1+\sqrt{1+8E}}2\right\rfloor\right\}=D_E+1. \tag{9}\] All \(A^{(j)}\) with \(1\leq j\leq r_E\) satisfy \(V\leq E\). On \(A^{(0)}\), a correct algorithm must query every one of these positions. Otherwise an unqueried \(j\) gives the same entire transcript on \(A^{(j)}\), yet requires a different answer. Hence at least \(r_E\) queries are necessary, and \(r_E=\Theta(1+\min\{n,\sqrt E\})\).
Independently, sorted arrays belong to the promised class. For a fixed sorted array, the search decision tree must distinguish \(n\) matching indices and absence. Each query has at most three outcomes, so its worst-case depth is at least \(\log_3(n+1)=\Omega(\log n)\). The larger of the two lower bounds is at least half their sum. This proves (5). ◻
Why a square root appears. In (8), the minimum moves \(j-1\) positions, while the \(j-1\) preceding entries each shift by one. Its large displacement contributes \((j-1)^2/2\) to the potential, and the smaller shifts contribute \((j-1)/2\). Thus \(\Theta(r^2)\) potential permits a target to hide among \(r\) candidate positions. The square root is a geometric obstruction to search, not an assumption about a particular sorting algorithm.
What the lower bound says historically.
The sorted-array term \(\Omega(\log n)\) is the familiar decision-tree obstruction from classical searching [4]. The new obstruction is positional: on the absent instance \(A^{(0)}\), every one of the first \(r_E\) indices must be checked because any unqueried index could hold the minimum in another promised instance. This is why counting possible rank words alone is not a substitute for the adversary argument. The quadratic cost of hiding one key turns the global rank statistic into a \(\sqrt E\) query penalty.
Equal potential budgets, different searchable structure
Theorem Theorem 2 is tight when only \(E\) is supplied. A more descriptive promise can permit substantially faster search. The following separation makes that distinction explicit; it compares maxima over families, not equal-potential individual inputs.
This distinction echoes the presortedness literature [7] [6]: two measures can assign similar numerical “amounts of disorder” while supporting different algorithms. Here even the same measure and the same maximum budget lead to different search costs when the known families constrain where displacement can occur. One family concentrates potential in a single long move; the other disperses it over many short moves.
Proposition 3. Let \(r\geq2\), \(E=r(r-1)/2\), and \(n\geq2E\). There are two known families of length-\(n\) arrays with maximum potential exactly \(E\), whose optimal worst-case search costs are respectively \(\Theta(\log n+r)\) and \(\Theta(\log n)\).
Proof. Define \(\mathcal C_{\mathrm{conc}}\) by taking an arbitrary sorted array, removing its minimum, and inserting it at a position \(j\in\{1,\ldots,r\}\). Its rank words are precisely those in (8), so its maximum potential is \(E\). Search by scanning the first \(r\) entries, then binary-searching the sorted suffix if necessary. This uses \(O(r+\log n)\) queries. Every array used in the hiding argument belongs to \(\mathcal C_{\mathrm{conc}}\), including \(A^{(0)}\). That argument supplies \(\Omega(r)\), and the sorted subfamily supplies \(\Omega(\log n)\), proving the matching bound.
Define \(\mathcal C_{\mathrm{spread}}\) by taking an arbitrary sorted array and independently swapping any subset of the \(E\) fixed pairs \((1,2),(3,4),\ldots,(2E-1,2E)\). Each swapped pair contributes \((1^2+(-1)^2)/2=1\) to \(V\). Swapping every pair gives \(V=E\), but every array has \(d\leq1\). The search procedure (6) with \(D=1\) uses \(O(\log n)\) queries. The sorted subfamily gives the matching lower bound. ◻
| Known arrangement of disorder | Maximum \(V\) | Optimal search |
|---|---|---|
| One minimum moved within a prefix of length \(r\) | \(E\) | \(\Theta(\log n+\sqrt E)\) |
| Many independent adjacent-pair swaps | \(E\) | \(\Theta(\log n)\) |
For \(n=2E=r(r-1)\) and \(r\to\infty\), these costs become \(\Theta(\sqrt E)\) and \(\Theta(\log E)\). The same total potential can describe one deeply displaced item or many shallow displacements. The family promise tells search which geometry is possible; the scalar budget alone does not.
Recent work offers nearby, but distinct, ways to provide richer information. Bai and Coester [10] study sorting with possibly erroneous positional predictions. Narasimhan, Radhakrishnan, and Subramanian [11] study searches on approximately sorted arrays under disorder metrics including maximum displacement. Those settings emphasize the quality and form of the side information; Proposition Proposition 3 isolates the value of a family-level location promise even when its maximum potential is fixed.
The balance law and its computational meaning
Potential accounting became a standard way to analyze sequences of operations in data structures; for example, Sleator and Tarjan use it to study self-adjusting search trees [8]. The relevant lesson is that a change in potential can account for progress across operations, provided the relation between that change and actual operation cost is established. Here the potential has a geometric origin in Landers’s permutohedral model [12]. The balance identity is exact, while any conversion of it to a running-time statement needs an explicit preprocessing algorithm and cost model.
For a preprocessing trajectory \(x^{(0)},\ldots,x^{(B)}\), let \(\Delta_k=V(x^{(k)})-V(x^{(k+1)})\) and \(A_B=\sum_{k=0}^{B-1}\Delta_k\). Telescoping gives \[\boxed{V(x^{(0)})=A_B+V(x^{(B)}).} \tag{10}\] For inversion-removing adjacent swaps, \(\Delta_k>0\); swapping adjacent ranks \(a>b\) gives \(\Delta_k=a-b\) [12]. In the continuous relaxation \(\dot x=-\nabla V\), differentiation gives \(\dot V=-\|\nabla V\|_2^2\), and integration yields \[V(x(0))=V(x(t))+\int_0^t\|\nabla V(x(s))\|_2^2\,ds. \tag{11}\] Kendall’s inversion distance counts each inversion-removing adjacent swap as one step, whereas the decrease in \(V\) for such a swap is the rank gap \(a-b\). The potential therefore records more than the number of local repairs: it also reflects how far the exchanged ranks lie apart. This is the same distinction that makes a deeply displaced item costly in Theorem Theorem 2. Thus initial disorder equals residual disorder plus accumulated decrease. If \(V(x^{(0)})\leq E_0\) and preprocessing certifies a decrease of at least \(a\), then \(V(x^{(B)})\leq E_0-a\). Theorem Theorem 2 gives the tight guarantee from this numerical promise alone, with \(E=E_0-a\). Proposition Proposition 3 shows why additional location information can improve it.
This is an exact potential balance and a sharp search guarantee, not an equality between elapsed computation and savings. \(B\) counts trajectory steps, not all comparisons needed to choose or certify them. With preprocessing cost \(C_P\) and \(q\) subsequent searches, total cost is \(C_P+\sum_{j=1}^q C_S(A',y_j)\). The further question is how cheaply preprocessing can produce both low residual potential and useful structural certificates. The note connects established adaptive search machinery [9] to the geometric potential; it makes no claim of priority.
The contemporary frontier: from a quantity to a certificate
Two strands of 2026 work sharpen the surrounding questions without answering the search problem studied here. Ansari and Rockel [14] investigate the attainable relation between Spearman’s footrule and quadratic rank difference, including improved inequalities for finite rankings. Their results concern relations among measurements of disorder. The present search theorem asks what one such measurement, given as a worst-case promise, allows an algorithm to infer about the location of a queried key.
Rutschmann [13] studies a different information model: sorting when a partial order is already known. There, the preprocessing input explicitly records pairwise order constraints, and the number of compatible linear orders governs the remaining sorting problem. That line, from Fredman [5] to the 2026 result, makes the cost of preparing and using structural knowledge central. In the present setting, a certificate such as a bound on maximum displacement, or a promise of locally confined swaps, likewise has value beyond the scalar potential budget. Determining the least preprocessing cost needed to produce such a certificate is the natural next question suggested by the balance law and the separation in Proposition Proposition 3.
References
- C. Spearman. The proof and measurement of association between two things. American Journal of Psychology 15(1):72–101, 1904. doi:10.2307/1412159.
- M. G. Kendall. A new measure of rank correlation. Biometrika 30(1–2):81–93, 1938. doi:10.1093/biomet/30.1-2.81.
- R. Rado. An inequality. Journal of the London Mathematical Society s1-27(1):1–6, 1952. doi:10.1112/jlms/s1-27.1.1.
- D. E. Knuth. The Art of Computer Programming, Volume 3: Sorting and Searching. Addison-Wesley, 1973; 2nd ed., 1998. Author’s publication page.
- M. L. Fredman. How good is the information theory bound in sorting? Theoretical Computer Science 1(4):355–361, 1976. doi:10.1016/0304-3975(76)90078-5.
- P. Diaconis and R. L. Graham. Spearman’s footrule as a measure of disarray. Journal of the Royal Statistical Society, Series B 39(2):262–268, 1977. doi:10.1111/j.2517-6161.1977.tb01624.x.
- H. Mannila. Measures of presortedness and optimal sorting algorithms. IEEE Transactions on Computers C-34(4):318–325, 1985. doi:10.1109/TC.1985.5009382.
- D. D. Sleator and R. E. Tarjan. Self-adjusting binary search trees. Journal of the ACM 32(3):652–686, 1985. doi:10.1145/3828.3835.
- Y. Disser and S. Kratsch. Robust and Adaptive Search. STACS 2017, LIPIcs 66, 26:1–26:14. doi:10.4230/LIPIcs.STACS.2017.26.
- X. Bai and C. Coester. Sorting with predictions. Advances in Neural Information Processing Systems 36, 2023. Proceedings page.
- A. Narasimhan, S. Radhakrishnan, and C. R. Subramanian. On searching an approximately sorted array. Preprint, 2024. doi:10.21203/rs.3.rs-4577262/v1.
- J. R. Landers. Sorting as Gradient Flow on the Permutohedron. arXiv:2504.16706v2, 2026.
- D. Rutschmann. Sorting under partial information with optimal preprocessing time via unified bound heaps. arXiv:2604.12653, 2026.
- J. Ansari and M. Rockel. The exact Spearman rho-footrule region via optimal transport with applications to finite rankings, mixability, and Chatterjee’s rank correlation. arXiv:2608.20176, 2026.