WorksComputer Science
Ulam Metric -Center in Parameterized Linear Time
Abstract
Continuous Ulam Metric -Center asks for at most permutations whose radius- balls cover the input rankings. For rankings of symbols, a deterministic algorithm takes word operations. Permanent reference rankings, short insertion lists, and small obstructions obtained by patience sorting control the search. For one center, this answers a question of Bai, Fomin, Golovach, More, and Wietheger with linear input dependence. An arbitrary-alphabet Hamming embedding with a nonexpansive retraction also gives the matching exclusion under the Exponential Time Hypothesis.
Introduction
Background and the source problem
A consensus ranking should remain close to the rankings it summarizes. Data with several distinct groups may require several centers. Ulam distance measures how many symbols must be moved while the other symbols retain their relative order. The radius is a useful parameter when each ranking disagrees with its group’s consensus on only a few items. For example, moving the symbol in 12345 gives 13245, so these rankings have Ulam distance one.
Let and let be an -symbol alphabet. For permutations of , define
where denotes longest common subsequence length. Given input permutations and integers , , continuous Ulam Metric -Center asks for at most permutations such that
The centers may be arbitrary permutations; they need not be inputs. This is the convention of Bai, Fomin, Golovach, More, and Wietheger [1 Section 1.1].
Bai et al. prove NP-hardness even for when is part of the input, and give an exact algorithm in time
[1 Theorems 1 and 2] For one center, the parameter dependence is . By comparison, the Hamming-distance consensus problem Closest String has dependence over arbitrary alphabets, by the bounded-search-tree algorithm of Gramm, Niedermeier, and Rossmanith [7 Theorem 1]. Bai et al. ask whether the Ulam problem has the same dependence [1 Section 5, p. 19:21].
Question 1 (Bai–Fomin–Golovach–More–Wietheger). Can continuous Ulam Metric 1-Center be solved in time ?
Contribution
Theorem 2. For , continuous Ulam Metric -Center can be decided deterministically in
word operations, and a set of centers can be returned on every yes-instance. The permutations are given explicitly as arrays of symbols in ; a word holds an input address or a symbol.
For , this is , answering Question 1 while retaining linear dependence on the explicit input size. The boundary case amounts to counting distinct input permutations and can be solved by direct comparisons to at most representatives in time.
The radius dependence for one center is also optimal in the following standard conditional sense.
Theorem 3. Unless the Exponential Time Hypothesis fails, continuous Ulam Metric 1-Center has no algorithm with running time .
Theorem 3 does not assert optimal dependence on . The lower-bound statement was already made in the conclusion of Bai et al.; § 5 supplies an arbitrary-alphabet reduction that justifies its use of the Closest String lower bound.
The main obstacle to the algorithm is that a radius- ball can contain permutations. Guessing the moved symbols and their new positions would put the parameter in the exponent of the input size. Three ingredients avoid that enumeration.
A failed candidate has an obstruction on at most symbols. Stopping patience sorting after replacements produces this obstruction within operations (Lemma 4).
Relative to a fixed reference ranking, a symbol has at most relevant insertion cuts. Canonical cuts ensure that partial placements continue to agree with one fixed solution outside the still unguessed moved symbols (Lemmas 5–7).
Each center keeps its own permanent reference. An uncovered input either supplies a reference for a new cluster or exposes a new moved symbol for an existing center. At most references and moved symbols are introduced (§ 4).
The source already uses a search that creates candidate centers from uncovered inputs. Its local steps use permutation graphs, short lists of one-symbol moves, and suitable two-colorings; the full version constructs a coloring family of size [2 Lemmas 11, 13, 16 and Algorithm 1]. Here the references remain fixed while partial placements accumulate. A small obstruction selects a new symbol directly, avoiding the coloring family. The compatibility argument preserves the association of each reference with a distinct true cluster, so the input partition need not be guessed. Intermediate candidates need not cover the same inputs at every stage; the final coverage test certifies the solution.
The linear input factor uses only a threshold version of the classical patience-sorting algorithm, not a faster unrestricted longest-increasing-subsequence algorithm. Almost all scanned symbols extend the list of pile tops in constant time; only operations can require binary search before either success or an obstruction is known.
Related work
Bachmaier, Brandenburg, Gleißner, and Hofmeier proved NP-completeness of maximum rank aggregation under Ulam distance, among other metrics [3 Theorem 3]. Their bounded-modification-set framework also gives fixed-parameter algorithms for Kendall tau, Hamming, and Minkowski distances; Ulam distance is not among those algorithmic instantiations [3 Section 6]. Choosing an input permutation gives the familiar factor-2 metric approximation. For input rankings, Chakraborty, Gajjar, and Jha obtain a deterministic -approximation in time [4 Theorem 1]. More recently, Azgor, Chakraborty, Cuong, Das, Habib, and Nguyen prove that, for each , approximating the continuous center within is NP-hard even for four rankings [11 Theorem 1.3]. This rules out polynomial-time exact optimization for fixed , unless P equals NP; it is compatible with an exact algorithm parameterized by the radius.
The discrete center problem restricts the center to an input permutation. Abboud, Bateni, Cohen-Addad, Karthik C. S., and Seddighin study its fine-grained complexity and give a -approximation [9 Theorems 1 and 3]. Fischer, Goldenberg, Habib, and Karthik C. S. subsequently establish conditional optimality, up to subpolynomial factors, of the pairwise-distance algorithm when the permutation length is polynomially related to the number of inputs [10 Theorem 2]. Those results concern a different solution space and polynomial input-size dependence, rather than the radius dependence of the continuous problem considered here.
The lower-bound comparison requires attention to the alphabet. Lokshtanov, Marx, and Saurabh exclude dependence for Closest String over unrestricted alphabets [8 Theorem 3.1]. The proof of Lemma 18 in Bai et al.’s full version uses a binary pair encoding [2 Section 3.3]. Fixed-alphabet Closest String has single-exponential algorithms [8 Section 3]; for the binary case, Fischer and Habib give a randomized -time algorithm [6 Theorem 1]. Thus the binary encoding alone does not transfer the unrestricted-alphabet lower bound. The marker construction in Section 5 handles any alphabet size and projects arbitrary permutation centers back to strings without increasing distances. It therefore completes the lower-bound argument anticipated in the source.
Deletion witnesses and small obstructions
For , write for the subsequence induced by . A deletion witness between and is a set such that
Equivalently, if and only if such a witness of size at most exists. In particular, a reference ranking within distance of a center agrees with that center outside some set of at most symbols. No uniqueness of is assumed.
The following algorithm gives both the distance test and the obstruction needed for branching. The elementary patience-sorting principle is classical; see Aldous and Diaconis [5].
Lemma 4 (Threshold test and obstruction). Given permutations , the inverse-position array of , and , one can either certify or find such that
This takes operations and memory.
Proof. Read the symbols of and replace each by its position in . A common subsequence of the permutations is exactly an increasing subsequence of this sequence of distinct ranks. Maintain piles whose tops are increasing. A new rank starts a new pile on the right; otherwise place on the leftmost pile whose top exceeds . Call the latter operation a replacement. For an empty list, the first rank starts the first pile.
After any prefix, is the smallest possible final rank of an increasing subsequence of length . To verify the invariant, suppose replaces . If , an increasing subsequence ending at extends to one of length ending at ; for the singleton suffices. There was no subsequence of length ending below , by the minimality of the old . Nor can end a subsequence of length greater than , since that would require an old subsequence of length ending below . The other minima are unchanged. If starts a new rightmost pile, the same extension gives a subsequence of length , and no longer one can be created by one new rank. This proves the invariant by induction. Thus is the longest increasing subsequence length of the scanned prefix.
After ranks, the number of replacements is , because every other operation starts one pile. This deficit never decreases. Stop at the -st replacement. If the whole sequence is scanned first, its deficit is the Ulam distance, so the test succeeds.
On stopping, let be the non-singleton piles and let contain their symbols. Each pile is decreasing in scan order, so an increasing subsequence of contains at most one symbol from each pile. Moreover,
Consequently and its longest increasing subsequence has length at most , proving (2).
Compare each rank first with the rightmost top. Appending costs constant time, and a replacement uses binary search in time. There are at most replacements. Store the symbols of each pile, and keep a list of the piles that have become non-singleton; their union can then be collected in time. The claimed bounds follow.
Small cut lists
Fix an arbitrary reference permutation . A cut of the reference permutation is an integer ; it is the gap after the first symbols of . For a symbol and a cut , define
For an input permutation , define the predecessor set of in by
Define the cut list
The key point is that, although there are possible cuts, only of them can be relevant for any fixed input and symbol.
Lemma 5 (Small cut lists). For every input and every symbol ,
Proof. Put and . For every listed cut,
Thus lies in an interval containing at most integers. As ranges from to , the value runs through . Each value occurs once except , which occurs twice, immediately before and after the reference position of . Consequently
For computation, begin with and scan . Passing a symbol of decreases the value by one, passing a symbol outside increases it by one, and passing leaves it unchanged. The inverse-position array of gives membership in in constant time. Thus the list can be computed in time, without any assumption on .
Now fix a permutation with , a deletion witness of size at most between them, and put . For , let
Because , the set is a prefix of . Define the canonical cut of by
Then . In particular, the exact definition (3) assigns the same cut to all moved symbols occupying the same gap of the stable order .
Lemma 6 (Canonical cuts are listed). Let and be as above, and let . Let be a deletion witness of size at most between and . If , then the canonical cut belongs to .
Proof. Consider a symbol . Since , the definition of the canonical cut gives if and only if , which means that precedes in . Also , so and order and in the same way. Therefore
All possible disagreements between and are therefore contained in . Neither predecessor set contains , so the disagreements are in , a set of size at most . Hence , so .
Example. Let , let , and take . For the symbol , the predecessor set in is . Direct inspection gives
cut 5 is excluded because its predecessor set differs from in three symbols. The permutation has reference-deletion set , and the canonical cut of 3 is cut 1, immediately after the symbol 1. Thus the cut needed by this permutation is indeed present in the local list, as Lemma 6 guarantees in general.
We next formalize partial placements. A state consists of
where , , is a set of symbols guessed to be moved relative to , assigns a full-reference cut to every guessed symbol, and is a total order of . The candidate permutation is obtained by deleting every symbol of from and reinserting each at cut : smaller numerical cuts come first, and equal cuts are ordered according to . Formally, write for the rank of in , note that , and sort all symbols lexicographically by
This lexicographic definition remains unambiguous when a cut endpoint is itself a symbol of deleted from the reference.
Lemma 7 (Reconstruction of compatible states). Let be the order induced by on . Suppose that , that for every , and that . Put . Then
Proof. Set , so that . Both permutations induce the order on .
Let and . In , the symbol precedes if and only if , equivalently . By the definition of , this is also equivalent to preceding in .
It remains to compare two symbols . The sets and are prefixes of the same order. If , then the definition (3) gives , so precedes in . Choosing also gives in . The case is symmetric. Finally, if , then , and both permutations order according to . Thus every pair in has the same relative order in the two permutations, proving (4).
The reconstruction can be implemented without sorting all symbols. Sort the at most moved symbols by , then scan the cuts . At a positive cut , first output the reference symbol in position if it is not moved; next output the moved symbols assigned to cut in their prescribed order. At cut zero only the moved symbols are output. This realizes the lexicographic keys above in time.
The search over several centers
A search node contains records
Each reference is an input permutation and remains fixed for the lifetime of its record. The other data are a partial placement relative to that reference, with ; denote its reconstructed candidate by . Initially there is one record with and .
At a node, perform the following steps.
Construct the candidates. If every input is within distance of some candidate, return these candidates and accept.
Otherwise choose an uncovered input . If , create one child that adds the record .
For each existing record with , use Lemma 4 to find an obstruction between and . For each , each , and each of the insertion positions in , create a child that adds with this cut and order position to record . Here is the cut list computed relative to . Keep all other records and all earlier placements unchanged.
Reject if every child rejects.
The algorithm does not reject an instance merely because two inputs are farther than apart: they may be covered by different centers.
Proof of Theorem 2. If , the inputs themselves are a solution. If , any input is a center. Hence assume and . Soundness follows from the coverage test at every accepting node.
For completeness, fix a feasible set of at most true centers and assign each input to one true center that covers it. Empty clusters can be omitted. A compatible node associates its records injectively with true centers, with each reference belonging to its associated cluster. Write for the center associated with record . When a record is created, fix a deletion witness , , between and . Compatibility further requires
where is the canonical cut defined using , , and the last equality identifies a total order with its ordered sequence. Lemma 7 gives, with ,
The initial node is compatible by associating its sole record with the true center assigned to .
Consider an uncovered input at a compatible node. If its assigned true center is not represented by a record, there are fewer records than true centers and hence . The new-record child is compatible: associate it with that true center and choose its witness . Its moved set is empty, so every placement condition is satisfied.
Otherwise let be the record associated with the assigned true center. Choose a deletion witness , , between and . Since is uncovered, the obstruction satisfies (2). It contains a symbol in . Indeed, if it contained no such symbol, then would be disjoint from . (5) and the witness property of would give
Deleting , at most symbols, would therefore make the restricted permutations equal, contradicting (2).
Choose . In particular, , so this record is eligible for extension. The symbol is moved relative to its reference and is kept by the witness . Lemma 6 places its canonical cut in . The algorithm includes the child selecting this cut and the insertion position that extends the current order to . This child is compatible.
Thus every compatible nonaccepting node has a compatible child. Each transition either adds a record or increases one moved set. There are at most record additions and moved-symbol additions, so no path has more than transitions. A compatible path must therefore accept. This proves completeness without any assumption that coverage is monotone along the path.
There is at most one new-record child, and the extension of each record has at most choices. The branching factor is at most
The depth bound gives nodes. Since , this is .
Precompute the inverse-position arrays of all inputs in time. At a node, reconstructing all candidates costs . Coverage testing uses at most applications of Lemma 4. For the uncovered input, the same routine provides each required obstruction. There are relevant symbols, and each cut list takes time. These costs are bounded by a polynomial in times , using . Creating or copying a child record adds only a polynomial factor in , already absorbed in the search bound. This proves (1) in the stated word model.
Hamming retractions and the radius lower bound
An isometric encoding alone would not suffice for the lower bound: a permutation center outside the encoded strings could conceivably have a smaller radius. The following construction provides a simultaneous projection for all inputs. Write for Hamming distance.
Lemma 8 (Arbitrary-alphabet retraction). For every and , there are maps
computable in polynomial time such that is the identity and
Consequently, replacing each input string by its encoding preserves the optimal radius with any prescribed number of arbitrary centers.
Proof. For coordinate , use a disjoint block of symbols . Define
with an empty initial or final anchor string at the endpoints. Distinct values of give distinct block permutations that share all anchors in order. Thus their Ulam distance is one. Set
Both encodings place the disjoint blocks in the same order, so their longest common subsequence lengths add over the blocks. This proves (6).
For an arbitrary permutation , restrict it to each block . If for some , put ; otherwise put . The canonical block permutations are distinct, so this is well-defined and . If , then the two block restrictions differ, since equal restrictions receive equal decoded letters. Their Ulam distance, being a nonnegative integer, is at least one. Therefore
Any common subsequence of , restricted to , is a common subsequence of their block restrictions. Summing these upper bounds on the subsequence length and subtracting from gives
which proves (7).
An encoded family of string centers achieves the same radius by (6). Conversely, decode each arbitrary permutation center. For every input string , applying (7) with shows that its distance to the decoded center is no greater than its encoded distance to the original center. This works for every input and every center simultaneously, proving equality of optimal radii.
For example, when the three letters are represented by , , and . The marker moves while the two anchors retain their order. A noncanonical order such as may be decoded as zero: it differs from every canonical order, so the possible unit Hamming cost is always paid for by its Ulam distance.
Proof of Theorem 3. Lokshtanov, Marx, and Saurabh prove that Closest String has no -time algorithm under ETH [8 Theorem 3.1]. In their construction from Hitting Set, the strings have length , alphabet size , and radius . Applying Lemma 8 yields permutations of
symbols, with the same number of inputs and the same radius. The expansion is polynomial, and the lemma gives equivalence even when the permutation center is unrestricted. A Ulam algorithm in the excluded time would therefore solve these Closest String instances in the time excluded by the cited theorem.
Concluding remarks
For one center, the upper and lower bounds determine the radius dependence up to constant factors in the exponent under ETH, with a linear factor in the explicit input size for the upper bound. For several centers, the remaining question is the best joint dependence on and . The present argument bounds the number of introduced references and moved symbols separately; the one-center lower bound alone does not settle the cost of coordinating many clusters.
References
- [1]Tian Bai, Fedor V. Fomin, Petr A. Golovach, Yash Hiren More, and Simon Wietheger. Clustering permutations under the Ulam metric: A parameterized complexity study. In Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele Puppis, editors, 53rd International Colloquium on Automata, Languages, and Programming (ICALP 2026), volume 374 of Leibniz International Proceedings in Informatics (LIPIcs), Article 19, pages 19:1–19:23. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2026. https://doi.org/10.4230/LIPIcs.ICALP.2026.19.
- [2]Tian Bai, Fedor V. Fomin, Petr A. Golovach, Yash Hiren More, and Simon Wietheger. Clustering permutations under the Ulam metric: A parameterized complexity study. Full version of the ICALP 2026 paper, arXiv:2604.25734v1 [cs.DS], 2026. https://arxiv.org/abs/2604.25734.
- [3]Christian Bachmaier, Franz J. Brandenburg, Andreas Gleißner, and Andreas Hofmeier. On the hardness of maximum rank aggregation problems. Journal of Discrete Algorithms, 31:2–13, 2015. https://doi.org/10.1016/j.jda.2014.10.002.
- [4]Diptarka Chakraborty, Kshitij Gajjar, and Agastya Vibhuti Jha. Approximating the center ranking under Ulam. In 41st LARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS 2021), volume 213 of LIPIcs, Article 12, pages 12:1–12:21, 2021. https://doi.org/10.4230/LIPIcs.FSTTCS.2021.12.
- [5]David Aldous and Persi Diaconis. Longest increasing subsequences: From patience sorting to the Baik–Deift–Johansson theorem. Bulletin of the American Mathematical Society, 36(4):413–432, 1999. https://doi.org/10.1090/S0273-0979-99-00796-X.
- [6]Nick Fischer and Mursalin Habib. An optimal algorithm for binary closest string. arXiv:2605.31417v1 [cs.DS], 2026. https://arxiv.org/abs/2605.31417.
- [7]Jens Gramm, Rolf Niedermeier, and Peter Rossmanith. Fixed-parameter algorithms for Closest String and related problems. Algorithmica, 37(1):25–42, 2003. https://doi.org/10.1007/s00453-003-1028-3.
- [8]Daniel Lokshtanov, Dániel Marx, and Saket Saurabh. Slightly superexponential parameterized problems. SIAM Journal on Computing, 47(3):675–702, 2018. https://doi.org/10.1137/16M1104834.
- [9]Amir Abboud, MohammadHossein Bateni, Vincent Cohen-Addad, Karthik C. S., and Saeed Seddiqighin. On complexity of 1-center in various metrics. In APPROX/RANDOM 2023, volume 275 of LIPIcs, Article 1, 2023. https://doi.org/10.4230/LIPIcs.APPROX/RANDOM.2023.1.
- [10]Nick Fischer, Elazar Goldenberg, Mursalin Habib, and Karthik C. S. Hardness of median and center in the Ulam metric. In ESA 2025, volume 351 of LIPIcs, pages 111:1–111:17, 2025. https://doi.org/10.4230/LIPIcs.ESA.2025.111.
- [11]Sk Ruhul Azgor, Diptarka Chakraborty, Le Van Cuong, Debarati Das, Mursalin Habib, and Tien Long Nguyen. Ulam rank aggregation is hard to approximate for four rankings. arXiv:2609.05874v1 [cs.CC], September 2026. https://arxiv.org/abs/2609.05874v1.