Skip to content
DAH
Wiki/Graph AlgorithmsAlgorithmEmerging

Generalized sorting: sorting with comparisons allowed only along a graph

Sort n items when only pairs joined by edges of a given graph can be compared. Accepted bound: about n^(3/2) comparisons; two November 2026 preprints claim n^(4/3) and n·polylog n.

On this page13 sections
Why other work relies on it

It is the cleanest model of sorting under restricted or priced comparisons, and it is a testbed for query-complexity techniques (sampling, prediction repair) that apply to other problems where information is only available through a constrained set of probes.

Sorting when you may compare only pairs of items joined by an edge of a given graph.

  1. 1Compare only along edges of a graph
  2. 2Hidden order lies on a path in it
  3. 3Sample edges, predict all directions
  4. 4Repair prediction with few comparisons
  5. 5Total near n log n claimed, unrefereed

The model. There are nn items with a hidden total order. A known graph GG says which pairs can be compared, and one comparison on an edge reveals which endpoint is smaller. The graph contains a Hamiltonian path in sorted order, so the order is recoverable. The cost is the number of comparisons. For the complete graph the problem is ordinary comparison sorting, which needs Θ(nlog⁡n)\Theta(n\log n) comparisons: there are n!n! possible orders and each answer at best halves the possibilities, so at least log⁡2(n!)≈nlog⁡2n\log_2(n!)\approx n\log_2 n answers are needed.

Why it is harder in general. A comparison along an edge settles only that edge. With a sparse graph one can compare along every edge, costing mm comparisons for mm edges. With a dense graph the interesting question is how to choose which few edges to ask about, using the answers to infer others. If a<ba<b and b<cb<c are answered, then the edge (a,c)(a,c), if present, is known without asking. The difficulty is that the useful chains may be hidden among many edges that look alike.

Known results. Randomized algorithms by Huang, Kannan and Khanna use about min⁡(m,n3/2)\min(m,n^{3/2}) comparisons (2011); Kuszmaul and Narayanan reach O~(mn)\tilde O(\sqrt{mn}) and an optimal bound on random graphs (2021); sorting with predictions needs O(nlog⁡n+w)O(n\log n+w) comparisons when a guess with ww errors is given (2020). Two preprints from November 2026 claim O~(n4/3)\tilde O(n^{4/3}) (Behnezhad and Ferrante) and O(nlog⁡4n)O(n\log^4 n) (Khanna, Putterman and Song). Neither is refereed and DARC has not checked either.

Why it matters beyond sorting. The model is a clean testbed for query complexity: how much must be asked when answers come only through a restricted door. The prediction-then-repair idea (guess everything cheaply, then fix the mistakes with a budget proportional to the number of mistakes) is a general pattern.

Go deeper

The full technical text.

The model

There are nn items with a hidden total order π\pi. A known undirected graph GG on the items says which pairs may be compared; one comparison of an edge (u,v)(u,v) reveals which of u,vu,v is smaller. The graph is promised to contain a Hamiltonian path that visits the items in sorted order, so the order can in principle be recovered (without it, items with no comparable chain between them could not be ranked). The cost is the number of comparisons made, which may be chosen adaptively. When GG is the complete graph this is ordinary comparison sorting, which needs Θ(nlog⁡n)\Theta(n\log n) comparisons; so Ω(nlog⁡n)\Omega(n\log n) is a lower bound for every nn, and it is the only general lower bound on record.

The model goes back to sorting with priced or forbidden comparisons (Charikar et al., 2000); Huang, Kannan and Khanna studied it as generalized sorting (FOCS 2011).

What was known

Trivially, O(m)O(m) comparisons suffice (compare along every edge). Huang, Kannan and Khanna gave a randomized algorithm with O~(min⁡(m,n3/2))\tilde O(\min(m, n^{3/2})) comparisons, and asked whether n1+εn^{1+\varepsilon} comparisons are needed for some constant ε>0\varepsilon>0. Kuszmaul and Narayanan (FOCS 2021) improved this to O~(mn)\tilde O(\sqrt{mn}) for mm edges, which is no gain on dense graphs, and gave an optimal O(nlog⁡(np))O(n\log(np)) expected-comparison algorithm for Erdos-Renyi random graphs G(n,p)G(n,p) with the Hamiltonian path added. Lu, Ren, Sun and Zhang studied sorting with predictions: given a guessed orientation of every edge with ww mistakes, O(nlog⁡n+w)O(n\log n+w) comparisons suffice.

The November 2026 preprints (unrefereed)

  • Behnezhad and Ferrante, Generalized Sorting via Four-Cycles (arXiv:2611.06745, v1 4 November 2026) claim O~(n4/3)\tilde O(n^{4/3}) comparisons on every graph, breaking the nnn\sqrt n barrier, by querying edges that lie in many four-cycles and inferring the directions of the opposite edges.
  • Khanna, Putterman and Song, A Near-Optimal Generalized Sorting Algorithm (arXiv:2611.08397, v1 5 November 2026) claim a randomized algorithm using O(nlog⁡4n)O(n\log^4 n) comparisons in expectation on every graph. Their method builds a prediction of all edge orientations with O(nlog⁡n)O(n\log n) expected errors through repeated sampling and error-isolation passes, then repairs it with the Lu et al. prediction-repair algorithm. The authors state that an OpenAI model (ChatGPT "6-Astra") was essential to the improved bounds.

Neither preprint is refereed and DARC has not checked either argument. If the second holds, the answer to the Huang-Kannan-Khanna question is no.

What would remain open

Even then: whether O(nlog⁡n)O(n\log n) comparisons suffice on every graph (a log⁡3n\log^3 n factor separates the claim from the only lower bound), what the deterministic complexity is, and whether near-linear comparison counts can be reached by polynomial-time algorithms (the new algorithm is reported not to be). Lower bounds beyond Ω(nlog⁡n)\Omega(n\log n) are unknown for any graph family.

Words on this page (7)
Words on this page
graph
A set of points (vertices) with some pairs joined by lines (edges).
total order
A ranking in which any two items can be compared, so every item has a definite place in a single line.
comparison sort
A sorting method that learns the order only by asking which of two items is smaller.
Hamiltonian path
A route through a graph that visits every vertex exactly once.
big-O notation
A way to say how fast a quantity grows, ignoring constant factors; O(n log n) grows far slower than n squared.
randomized algorithm
A method that makes random choices, so its cost is judged on average over those choices.
sorting algorithm
A procedure that rearranges a list into order, such as smallest to largest.
New to this? Read first (4)
New to this? Read first
AI-reviewedAn AI drafted this explanation. Check it against the technical text.

Understanding map

map of the whole wiki →

What to read before Generalized sorting: sorting with comparisons allowed only along a graph (left), and what builds on it: entries that depend on it and its open problems (right). Every box links to its page.

  1. Start with
  2. Step 2
  3. Step 3
  4. Then

Open problems & questions

Progress timeline

  1. Nov 5, 2026
    Claimed O(n log^4 n) comparisons (preprint)
    Related to: Generalized sorting: is n·polylog n comparisons enough, and what is the exact complexity?

    Khanna, Putterman and Song posted arXiv:2611.08397 (v1, 5 November 2026). Unrefereed; DARC has not checked it.

    source
  2. Nov 5, 2026
    Claimed O(n log^4 n) comparisons (preprint)

    Khanna, Putterman and Song posted arXiv:2611.08397 (v1, 5 November 2026). Unrefereed; DARC has not checked it.

    source
  3. Nov 4, 2026
    Claimed Õ(n^(4/3)) via four-cycles (preprint)

    Behnezhad and Ferrante posted arXiv:2611.06745 (v1, 4 November 2026). Unrefereed.

    source
  4. Nov 4, 2026
    Claimed Õ(n^(4/3)) via four-cycles (preprint)
    Related to: Generalized sorting: is n·polylog n comparisons enough, and what is the exact complexity?

    Behnezhad and Ferrante posted arXiv:2611.06745 (v1, 4 November 2026). Unrefereed.

    source
  5. Nov 14, 2021
    Õ(sqrt(mn)) comparisons; optimal for random graphs
    Related to: Generalized sorting: is n·polylog n comparisons enough, and what is the exact complexity?

    Kuszmaul and Narayanan (FOCS 2021) gave O(n log(np)) expected comparisons for random graphs and Õ(sqrt(mn)) in general.

    source
  6. Nov 14, 2021
    Õ(sqrt(mn)) comparisons; optimal for random graphs

    Kuszmaul and Narayanan (FOCS 2021) gave O(n log(np)) expected comparisons for random graphs and Õ(sqrt(mn)) in general.

    source
  7. Oct 31, 2020
    Sorting with predictions: O(n log n + w)
    Related to: Generalized sorting: is n·polylog n comparisons enough, and what is the exact complexity?

    Lu, Ren, Sun and Zhang showed that a prediction of every edge with w errors can be repaired with O(n log n + w) comparisons, the tool later reused.

    source
  8. Oct 31, 2020
    Sorting with predictions: O(n log n + w)

    Lu, Ren, Sun and Zhang showed that a prediction of every edge with w errors can be repaired with O(n log n + w) comparisons, the tool later reused.

    source
  9. Oct 1, 2011
    Generalized sorting in Õ(n^(3/2)) comparisons

    Huang, Kannan and Khanna (FOCS 2011; the date is a placeholder for the symposium month) gave a randomized algorithm using about min(m, n^(3/2)) comparisons and asked whether n^(1+eps) is necessary. Bound as quoted in the later papers cited here.

    source
  10. Oct 1, 2011
    Generalized sorting in Õ(n^(3/2)) comparisons
    Related to: Generalized sorting: is n·polylog n comparisons enough, and what is the exact complexity?

    Huang, Kannan and Khanna (FOCS 2011; the date is a placeholder for the symposium month) gave a randomized algorithm using about min(m, n^(3/2)) comparisons and asked whether n^(1+eps) is necessary. Bound as quoted in the later papers cited here.

    source