Clustering Permutations Under the Ulam Metric:
A Parameterized Complexity Study
Abstract
Rank aggregation seeks a representative permutation for a collection of rankings and plays a central role in areas such as social choice, information retrieval, and computational biology. Two fundamental aggregation tasks are the center and median problems, which minimize the maximum and the total distance to the input permutations, respectively. While these problems are well understood under Kendall’s tau and related distances, their parameterized complexity under the Ulam metric, an edit-distance-based metric on permutations, has remained largely unexplored.
In this work, we initiate a systematic study of the parameterized complexity of rank aggregation under the Ulam metric. We consider both the center and median problems, as well as their generalizations to the -center and -median clustering settings, parameterized by the number of centers and the distance budget (corresponding to the maximum distance for center variants and the total distance for median variants). Both problems are known to be NP-hard already for .
We show that the Ulam -center problem remains NP-hard when , but is fixed-parameter tractable when parameterized by . Our algorithm is based on a novel local-search framework tailored to the non-local nature of Ulam distances. We complement this by proving that no polynomial kernel exists for the parameterization unless . For the Ulam -median problem parameterized by the total distance , we establish -hardness and provide an algorithm. We also provide a polynomial kernel for the parameter , which in turn yields a fixed-parameter tractable algorithm.
Keywords and phrases:
parameterized complexity, Ulam distance, rank aggregation, clusteringCategory:
Track A: Algorithms, Complexity and GamesFunding:
Tian Bai: Funded by the European Union, GA#101126560; Bergen research and training program for future AI leaders across the disciplines, LEAD AI and by the Trond Mohn forskningsstiftelse (grant no. TMS2023TMT01).Copyright and License:
2012 ACM Subject Classification:
Theory of computation Parameterized complexity and exact algorithms ; Mathematics of computing Permutations and combinationsEditors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele PuppisSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Rank aggregation is the problem of computing a representative ranking from a collection of permutations representing the preferences of individual voters. The roots for a mathematical investigation of this problem can be traced back to early studies of social choice theory and voting systems like Borda (1781) and Condorcet (1785), as well as later seminal works such as those by Arrow [4] or Diaconis and Graham [20]. Rank aggregation constitutes a fundamental task with broad applications in social choice theory, information retrieval, computational biology, and database systems [1, 4, 21, 30, 19]. Algorithmically, two canonical rank aggregation tasks are to compute the center and the median of permutations. Given a distance function on the space of permutations over symbols, the center of a permutation set is a permutation minimizing
whereas the median of is a permutation minimizing
Among distance measures for rank aggregation, Kendall’s tau and the Ulam metric are the two most natural and fundamental metrics, extensively studied in both theory and applications [14]. Kendall’s tau distance counts the number of pairwise disagreements between two permutations, thereby capturing local inconsistencies in ranking order. In contrast, the Ulam metric is an edit distance that measures the minimum number of element move operations (deletion and insertion) required to transform one permutation into another. This metric captures global structural differences by isolating the longest common subsequence (the elements that are not moved) and quantifying how many elements must be relocated to achieve alignment.
The tasks of computing centers and medians under Kendall’s tau metric are well understood from different computational perspectives [2, 10, 21, 22, 27, 30, 33]. Finding the optimal center or median under Kendall’s tau is -hard already if there are just four input permutations [10, 21]. Additionally, the median under Kendall’s tau, also known as Kemeny rankings, admits a polynomial-time approximation scheme (PTAS) [27]. Both versions of rank aggregation under Kendall’s tau admit fixed-parameter tractable (FPT) algorithms parameterized by the solution cost [5, 7], and other natural parameters [8, 9, 16, 17, 23].
In contrast, the study of rank aggregation under the Ulam metric is relatively unexplored, especially from the perspective of parameterized complexity. A key reason is that Ulam distance is a global measure whose combinatorial structure is inherently harder to exploit algorithmically than the local nature of Kendall’s tau. Consequently, some algorithmic work has focused on estimating the distance itself. Andoni and Nguyen [3] and Naumovitz et al. [29] developed sublinear-time approximation schemes to estimate the Ulam distance between two permutations, using connections to calculate the longest common subsequence.
Finding an optimal center under the Ulam metric was shown to be -hard over a decade ago [5], while the median problem was only recently proven -hard [24]. A folklore -approximation exists for both the median and center variants under the Ulam metric. Recently, Chakraborty et al. [15] obtained a -approximation (with any ) for the center problem with running time exponential in the number of input permutations . At a similar time, the first approximation algorithm to break the barrier of for the median problem appeared [12]. The subsequent work [13] extends the approximation framework to the setting of finding medians, achieving a similar approximation guarantee in time , where is the size of the alphabet and is the number of input permutations. Very recently, Jaiswal et al. [26] improved on this work and provided a randomized algorithm running in time. All three works on the median problem provide guarantees close to but below an approximation factor of .
To the best of our knowledge, no prior work has considered Ulam-based aggregation through parameterized exact algorithms, despite the metric’s intimate connection to edit distance and longest common subsequence – domains where parameterized techniques have proven highly effective. The clustering problems under the Ulam metric seem more challenging, as the Ulam metric is a more complex and less local measure than Kendall’s tau, which may suggest that the computational landscape of Ulam-based aggregation could be significantly different. One may notice that the Ulam distance is a smaller parameter than Kendall’s tau, as every permutation can be transformed into the other by only moving the elements that are in a different order in the two permutations. It may happen that two permutations with Ulam distance could differ in the relative order of an unbounded number of pairs of elements. This highlights a fundamental structural disparity between the two distance measures, which leads to the following natural question:
What is the parameterized complexity of rank aggregation under the Ulam metric?
1.1 Clustering Under the Ulam Metric: Definitions and Main Results
In this work, we initiate a systematic study of the parameterized complexity of rank aggregation under the Ulam metric. Beyond the classical parameter , which captures the solution cost (the maximum distance or the sum of distances, respectively), we consider substantially more general variants of the problem: -center and -median clustering under the Ulam metric [13]. These extensions, denoted by Ulam Metric -Center and Ulam Metric -Median, are both natural and well established in the rank aggregation literature. In these problems, one seeks representative permutations that minimize, respectively, the maximum distance to any assigned permutation (-center) or the total sum of distances (-median).
Formally, let be the set of all permutations over an alphabet of size , and let be the Ulam distance between and in (see Section 2 for the formal definitions). We define our problems of interest as follows.
Ulam Metric -Center
Input: An alphabet of size , a set of permutations , and integers and .
Task: Decide whether there exists a set of centers such that
Ulam Metric -Median
Input: An alphabet of size , a multiset of permutations , and integers and .
Task: Decide whether there exists a set of medians such that
We remark that, in both clustering problems, the centers or medians are not required to belong to the input set of permutations . Hence, we consider variants of the problems that are referred to as continuous in some literature. Both problems are known to be -hard already for : hardness for the center variant was shown by Bachmaier et al. [5] and for the median by Fischer et al. [24].
We summarize our main results in Table 1. Most notably, we establish fixed-parameter tractability for both problems when parameterized simultaneously by and . Prior to our work, the parameterized complexity of these two clustering problems with respect to was not even settled for the much simpler case .
We contrast this tractability result by establishing hardness for parameterization by alone: Ulam Metric -Center is already -hard on instances with . In contrast, Ulam Metric -Median is in parameterized by (that is, solvable in polynomial time for each fixed ), but is -hard for parameter , ruling out fixed-parameter tractability under well-established complexity assumptions. Finally, we discover yet another difference in the tractability landscapes of Ulam Metric -Center and Ulam Metric -Median. While the latter admits a polynomial-sized kernel, we rule out the existence of such a kernel for Ulam Metric -Center under established complexity assumptions. Our results for the Ulam metric complement the mature theory developed for Kendall’s tau. We also hope that they provide rigorous foundations for consensus ranking in applications where global structural coherence under the Ulam metric is essential.
In the following, we provide a detailed overview of our results and the techniques employed. Formal proofs are deferred to Sections 3 and 4. Some details and proofs marked by are omitted due to space constraints.
| Parameters | -center | -median |
|---|---|---|
| -hard even if [5] | -hard even if [24] | |
| -hard even if (Theorem 1) | -hard, (Theorems 5 and 4) | |
| (Theorem 2) | (Corollary 7) | |
| no polynomial kernel (Theorem 3) | polynomial kernel (Theorem 6) |
1.2 Contributions and Techniques for Ulam Metric -Center
The first group of results in our work concerns Ulam Metric -Center. As previous work already established that it is unlikely to obtain polynomial time algorithms even for instances aiming for center, it is natural to ask for the tractability on instances where we instead restrict the radius of the centers to . We answer this question negatively by establishing the -hardness of Ulam Metric -Center for is any positive constant at least . This hardness result is established via a reduction from the Vertex Cover problem on triangle-free graphs.
Theorem 1 ().
Ulam Metric -Center is -hard even if is fixed to any positive constant at least .
The construction for is relatively straightforward but closes an important gap: it establishes that parameterization by alone cannot yield fixed-parameter tractability under standard complexity assumptions. The main idea of the reduction is to construct an alphabet consisting of two symbols per vertex in the vertex cover instance. The input set contains one permutation per edge, all sharing a common base ordering except that the symbol pairs of the two endpoints of the edge are swapped in the respective permutation. A vertex cover then corresponds to a set of center permutations, each encoding a vertex by swapping the respective symbol pair in the base ordering. Then each permutation encoding an edge has Ulam distance to only those permutations encoding vertices to which the edge is incident, which ensures an equivalence between the vertex cover instance and the Ulam Metric -Center instance. We defer a formal proof to Section 3, but provide an exemplary reduction in Figure 1.
A nontrivial challenge is that a single permutation – swapping symbol pairs of multiple vertices – might cover several edges without corresponding to any single vertex in a cover. We circumvent this problem by basing our reduction on triangle-free instances of Vertex Cover, so this case will never occur. Furthermore, a direct reduction from the case to general is non-trivial; we overcome this by augmenting the construction with additional corresponding symbols for each vertex.
The -hardness of Ulam Metric -Center even if or if naturally raises the question of the parameterized complexity of the problem with the combined parameter . The following theorem establishes fixed-parameter tractability with respect to this combined parameter.
Theorem 2.
Ulam Metric -Center can be solved in time, where and .
On first glance, it may seem that the finite number of permutations in our space would allow for an approach based on some simple branching and local search around some permutation . This approach is infeasible, however, as for a permutation of length , there are permutations within Ulam distance from , each of which is a potential candidate for the center. This lower bound follows from a simple counting argument. One can choose symbols from the first half of in ways and insert them into the second half in at least distinct ways, yielding a unique permutation at Ulam distance at most from .
A natural alternative is to adapt techniques from string-based clustering, which typically perform bounded local search around a candidate solution and iteratively improve it by resolving “dissimilarities” with inputs that exceed the target distance . Such a paradigm is well-known and has been highly successful for problems such as Closest String [25] where the “dissimilarities” correspond to bits contributing to the Hamming distance. However, two permutations can admit distinct s of the same maximum length, making it impossible to pinpoint a canonical set of elements to guide local improvements. Thus, such techniques from string-based clustering cannot directly apply to the Ulam metric, and more involved methods are required. Our algorithm embarks on a similar approach as the one by Gramm et al. [25]. Rather sooner than later, however, the issue of not having a unique witness requires much more involved techniques and branching procedures tailored to the Ulam metric to establish fixed-parameter tractability.
In our algorithm, we construct a family of candidate permutations that are at bounded Ulam distances from hypothetical centers. These permutations will eventually converge towards the center permutations. If , then such a candidate can be initially chosen as an arbitrary permutation from ; note that it should be at the Ulam distance at most from a center in any YES-instance of the problem. For , we initiate the set of candidates using the idea behind the standard -approximation for the -Center problem. On each step, we either conclude that the current set of candidates can serve as centers, that is, each permutation in is at distance at most from one of the candidates, or find a guide permutation at distance at least from all the candidates. Then we can guess a candidate permutation that should be transformed to a center for the cluster containing the guide. Our crucial result (Lemma 16) shows that, given and , we can efficiently (in FPT time) enumerate a set of permutations with distance one to such that for any hypothetical center, there is a permutation in the set that is closer to the center than was, see Figure 2 for a visualization of this idea. The proof of Lemma 16 is rather sophisticated and combines the random separation [11] and branching techniques. The random separation is used to highlight elements of and that should be moved to make these permutations closer to the center and the neighbors of these elements that are not moved. Then we identify an element of that should be moved and, after that, find an appropriate place for this element using branching. Repeatedly invoking Lemma 16, we ensure that the candidate permutations converge to the centers.
The fixed-parameter tractability of Ulam Metric -Center with parameter established in Theorem 2 immediately leads to the question about the existence of a polynomial kernel for this problem. The following theorem provides a negative answer to this question.
Theorem 3 ().
Ulam Metric -Center does not admit a polynomial-sized kernel for the parameter unless .
The lower bound of Theorem 3 holds already for . The proof is based on a Polynomial Parameterized Transformation (PPT) reduction from the classical Closest String problem to Ulam Metric -Center. To build such a transformation, we employ a distance-preserving transformation between binary strings and permutations, where for every pair of binary strings, their Hamming distance is the same as the Ulam distance between the permutations to which they translate. The reduction establishes that from the perspective of parameterized complexity with respect to the radius , Ulam Metric -Center is at least as hard as Closest String. Theorem 3 then follows by pipelining the PPT with established lower bounds on the kernelization of Closest String by Basavaraju et al. [6].
1.3 Contributions and Techniques for Ulam Metric -Median
The second group of results is concerned with Ulam Metric -Median. Recall that the problem is -hard for [5]. While Ulam Metric -Center is also -hard for , this is not the case for Ulam Metric -Median. It is easy to obtain a polynomial-time algorithm for this problem for each fixed value of .
Theorem 4 ().
Ulam Metric -Median can be solved in time, where and .
The algorithm builds on a simple branching technique, where we observe that the medians can be obtained by applying a total of move-operations on the input set, and we branch on these moves by brute-force. The result in Theorem 4 is tight in the sense that the existence of an -algorithm for the parameterization by is unlikely due to the following lower bound.
Theorem 5.
Ulam Metric -Median is -hard parameterized by .
Our proof of Theorem 5 relies on a careful reduction from Multicolored Clique. The instance is designed in a way that all but one of the medians in any hypothetical solution are already present in the input set . The challenge is to find that additional median in a way that it is sufficiently close to a number of input permutations. Crucially, the permutations are designed in such a way that this is only possible if all edges covered by the median form a clique, see Figure 3 for a schematic example. On a high level, we construct the instance such that there is one special symbol per color, and the position of that symbol in the additional median encodes which vertex of that color is selected for the multi-colored clique.
Interestingly, our proof indicates that the hardness of the problem does not so much depend on identifying which symbols need to be moved but also importantly on deciding where to move these symbols.
In contrast to the lower bound on the polynomial kernel for Ulam Metric -Center obtained in Theorem 3, Ulam Metric -Median admits a polynomial kernel.
Theorem 6 ().
Ulam Metric -Median admits a kernel with permutations over an alphabet of size , computable in time, where and .
Our kernelization result is based on the observation that for any YES-instance of Ulam Metric -Median, contains at most distinct permutations. This allows us to reduce the size of . Then we reduce the size of the alphabet by making replacements of identical subpermutations by shorter ones. Here, we use the fact that two permutations at Ulam distance at least cannot belong to the same median in any solution. Thus, we can identify some sets of permutations such that every set of permutations that shares a median in a hypothetical solution is a subset to one of the sets. We show that the pairwise Ulam distance within each set are small. Combined with the fact that there are only few distinct permutations, this implies that in each set there are many (or long) identical subpermutations, which we can then shorten to reduce the size of the alphabet .
Combining Theorems 6 and 4, we immediately obtain an -algorithm with the following running time.
Corollary 7.
Ulam Metric -Median can be solved in time, where and .
2 Preliminaries
Basic notation.
We use to denote the set . Let be a finite alphabet with . A permutation of length over is a bijection . We write for the set of all permutations of length over . Thus, each is an ordering of the symbols of . We often write a permutation as a sequence .
A subsequence of a permutation is obtained by deleting zero or more elements from while maintaining the relative order of the remaining elements. A common subsequence of two permutations and is a subsequence that appears in both permutations. We denote by the length of the longest common subsequence of and .
Ulam distance.
A move operation on a permutation removes one element from its current position and inserts it at another position, while maintaining the relative order of all other elements.
For two permutations , the Ulam distance is the minimum number of move operations needed to transform into :
A classical identity characterizes this metric in terms of the longest common subsequence:
Thus, the Ulam distance measures the minimum number of elements that must be relocated to make the permutations consistent in relative order. We remark that a longest common subsequence, and thereby the Ulam distance, between two permutations of length can be computed in time in by relabeling the alphabet such that the first permutation has increasing order and then finding a longest increasing sequence in the other (relabeled) permutation. The Ulam distance on permutations is analogous to the Levenshtein edit distance on strings in the following sense: both distances identify a longest common subsequence and keep it untouched while performing edit operations on the remaining symbols.
For a set of permutations and , we write to denote the minimum distance from to any permutation in , that is, .
For two strings of equal length over an alphabet, the Hamming distance counts the number of positions where the corresponding symbols differ.
Graphs.
We work with simple undirected graphs. For a graph , we denote by its vertex set and by its edge set. A vertex cover of a graph is a subset such that every edge in has at least one endpoint in . A clique in a graph is a subset of vertices such that every pair of vertices in the subset is connected by an edge. A graph is triangle-free if it contains no clique of size . A proper vertex coloring of a graph assigns colors to vertices such that no two adjacent vertices share the same color.
Parameterized Complexity.
A parameterized problem is a language where is a set of strings over a finite alphabet . An input of a parameterized problem is a pair where is a string over and is a parameter. A parameterized problem is fixed-parameter tractable (or ) if it can be solved in time for some computable function . The complexity class consists of all fixed-parameter tractable parameterized problems. A parameterized problem is in the class if it can be solved in time for a computable function . The standard way to rule out the existence of an -algorithm for a parameterized problem under the standard parameterized complexity assumption that is to show that it is [1]-hard, that is, at least as hard as any problem in the class of parameterized problems . A problem is para--hard if it is -hard even when the parameter is a constant.
A kernelization algorithm or kernel for a parameterized problem is a polynomial-time algorithm that takes as its input an instance of and returns an instance of the same problem such that (i) if and only if and (ii) for some computable function . The function is the size of the kernel; a kernel is polynomial if is a polynomial. A decidable parameterized problem is if and only if it admits a kernel. However, up to some standard complexity-theoretic assumptions, there are problems that have no polynomial kernels. One of the ways to exclude a polynomial kernel for a parameterized problem is to show that there is a polynomial parameter transformation from a parameterized problem for which the existence of a polynomial kernel does not exist unless , where a polynomial parameter transformation is a polynomial-time reduction such that the parameter in the new instance is bounded by a polynomial in the original parameter.
3 The Complexity of Ulam Metric -Center
In this section, we study the Ulam Metric -Center problem. We first show that the problem is already -hard for . Our main result in this section is the fixed-parameter tractability of the problem parameterized by . Nevertheless, under standard complexity assumptions, the problem does not admit a polynomial kernel parameterized by .
3.1 Lower Bound for Constant Radius
We prove that Ulam Metric -Center is -hard when the radius is fixed to the constant , via a reduction from Vertex Cover. Notice that Vertex Cover remains -hard in triangle-free graphs [32]. This follows from a standard -subdivision transformation: replacing each edge by a path of length eliminates all triangles and increases the size of a minimum vertex cover by exactly one per original edge. We may thus assume without loss of generality that the input graph is triangle-free, which suffices to prove Theorem 1. The idea of the reduction is to have two symbols per vertex. All permutations relevant to the reduction look almost entirely the same, except that only the pair of symbols for one or two vertices are swapped to encode that respective vertex or edge. If we let the input set of permutations encode all edges of the graph this way, then a vertex cover corresponds to a set of permutations encoding vertices. This holds as each permutation encoding an edge has Ulam distance to only those permutations encoding vertices to which the edge is incident.
Theorem 1 (). [Restated, see original statement.]
Ulam Metric -Center is -hard even if is fixed to any positive constant at least .
3.2 Fixed-Parameter Tractability by
Since the problem is -hard even for constant or , neither parameter yields tractability on its own. We therefore consider the combined parameter , and show that the Ulam center problem is fixed-parameter tractable under this parameterization.
Our algorithm relies on iteratively updating candidate permutations to eventually converge towards the center permutations by moving one symbol in a candidate in each step. Specifically, given a candidate permutation and a guide permutation , we can enumerate (in time) a set of permutations that differ from by one move. Among them, at least one gets closer to any true center that covers both and . The key technical ingredient is captured in Lemma 16.
Our approach is based on the -colorings of the symbols in and . The -colorings encode which symbols are allowed to be moved toward a specific permutation . We formalize when such a -coloring is fitting with respect to , an exemplary coloring is visualized in Figure 4.
Definition 8 (-fitting coloring and witness).
Let , , and be a coloring function of . We say is a -fitting coloring (of ) with respect to some permutation , if there is a subset of symbols such that
-
and can be obtained from by moving the symbols in ;
-
for every symbol in , we have ; and
-
for every symbol , if appears in within symbols (before or after) of some symbol in , then .
Moreover, such a subset of symbols is called a witness of the coloring to be -fitting.
Intuitively, red symbols are candidates for being moved (i.e., they may or may not actually be moved), but blue symbols are definitely not moved. Moreover, if a red symbol is indeed one of the moved symbols (i.e., it belongs to ), then all symbols within distance of it must be correctly colored blue (if they are not moved) or red (if they are moved). In other words, whenever the coloring correctly identifies a moved symbol as red, it must also correctly color its entire -neighborhood.
Consequently, the red symbols in a -fitting coloring of w.r.t. that are not separated by consecutive blue symbols are tied to each other in the sense that either both or none of them belong to any witness . This motivates the following definitions of blocks.
Definition 9 (Blocks).
Let , and . A block is a maximal substring (i.e., consecutive sequence) of such that
-
the first and last symbols of are colored red; and
-
contains no consecutive blue symbols.
See also Figure 4 for a visualization of blocks. By definition, any two blocks are disjoint and separated by at least blue vertices in . We immediately obtain the following observation by recoloring all symbols in a block blue if it contains more than red symbols.
Observation 10.
Let , . Suppose is a -fitting coloring of w.r.t. some permutation . If , there is a -fitting coloring of w.r.t. such that there are at most red symbols in each block. Moreover, such a coloring can be obtained from in time.
We next argue how the notion of -fitting colorings and that of witnesses provide a means to find a permutation that is one step closer to any true center than the candidate .
Lemma 11.
Let , . Let and be -fitting colorings of and w.r.t. some permutation with and . Consider any symbol such that there are witnesses and of and , respectively, with . Then in time we can compute and enumerate a set with and there is with . The computation does not require the sets and as input.
Proof.
Consider an arbitrary pair and of witnesses. Intuitively, means that by moving to a specific new location in , we make closer to . As , the position of in gives an indication for that location.
To see where to move in , let be the closest symbol to the left of in that is still blue in both permutations, and let be the closest such symbol to the right of in . If there is no such symbol on the right and/or left, consider or to be a phantom blue symbol before/after the first/last symbol of the permutation, respectively. As does not contain any blue symbols, it does not contain any of and . Thus, as lies between and in , it lies between them in as well. As and are blue in as well, they do not change their position between and . We add all permutations to that are obtained by moving in to some location between and . This ensures that we consider all possible ways of moving closer to its position in , leading to the fact that always contains a permutation that is one step closer to than .
We argue that we only need to add at most such permutations to . Consider the next symbols to the left of in . Note that they belong to at most one block in . In each block, there are at most red symbols, and at least of these symbols are blue in . Thereby, these symbols do not appear in any witness of . Let be the set of these blue symbols (select the closest to , if there are more than ). As , the symbols in appear as a subsequence of which is interrupted only by at most other symbols. Call the set of these interrupting symbols . As the symbols in occur consecutively in , the symbols in appear consecutively in , except some potential interruptions by symbols in . Thus, the symbols in have a pairwise maximal distance of at most in . Thus, they belong to at most one block in and so at most of them are red in . Hence, there is a symbol which is blue in both and . The same line of argument shows that a suitable symbol exists among the symbols to the right of in .
As the distance between and is at most in and , the distance between and in is at most , giving that many possibilities on where to insert . If one or both of and are phantom symbols at the beginning/end of a permutation, the same upper bound applies.
We can find and in time by starting a search outwards from in . Listing all obtained permutations takes time in .
It remains to show how to find such a symbol . For technical reasons, we require a weak notion of consistency between two -fitting colorings, which motivates the following definition.
Definition 12 (Consistent -fitting colorings).
Let , , and be -fitting colorings of and with respect to some permutation , respectively. We say that and are consistent -fitting with respect to if there are respective witnesses , such that for every symbol , we have if and only if , and if and only if .
We first show how to enumerate a set of candidate pairs of colorings to be consistent -fitting with respect to any .
Lemma 13.
Let and . There is a set of -coloring pairs such that
-
the size of is bounded by ; and
-
for every with and , contains a consistent -fitting coloring pair of and w.r.t. .
Moreover, such a set can be computed and listed in time, where .
Proof.
We construct the collection using the notion of -universality. An -universal set is a set of bitstrings of length , such that for each subset of size , the projection of onto the coordinates in yields all possible bitstrings of length . Equivalently, if we restrict each string in to any fixed set of coordinates, all possible binary patterns appear. Naor, Schulman, and Srinivasan [28] showed that such a set exists with size at most , and can be listed in time .
In our setting, we take and . Applying the above, we obtain an -universal set of size
which can be listed it in time . Each bitstring in naturally defines a pair of -colorings of the symbols in : the first bits define the coloring of and the last bits define a coloring of .
Now, consider any permutation with and . Let and be minimum-sized sets of moved symbols in and , respectively, to obtain . By Definitions 8 and 12, the -colorings and are consistent -fitting w.r.t. if
-
(i)
every symbol in (resp., ) is colored red in (resp., );
-
(ii)
every symbol in (resp., ) within distance of a moved symbol in (resp., ) is colored blue in (resp., ); and
-
(iii)
every symbol in (resp., ) is colored blue in (resp., ).
Recall that both sets have size at most . The number of symbols involved in these conditions is at most
Because our -universal set contains all possible pairs of colorings on any set of positions, it must contain a pair that assigns suitable colors to all involved symbols. Hence, this pair is consistent -fitting w.r.t. .
Given a guide and the candidate , Lemma 13 allows us to guess a consistent -fitting coloring pair w.r.t. some center within distance of both. We now use the colorings and to capture the structural relationship between the two permutations. To this end, we consider a certain vertex cover of their permutation graph. Here, a permutation graph of two permutations is the graph whose vertex set is the alphabet and its edges are exactly the (unordered) pairs of vertices whose order is reversed between and . For each edge in , exactly one of and has the two incident symbols in the same order as the center . A vertex cover of thus gives an indication of which symbols need to be moved to transform and into .
Lemma 14.
Let , . Let and be consistent -fitting colorings of and w.r.t. some permutation . For every pair of witnesses for and there is an inclusion-wise minimal vertex cover of with .
Proof.
We begin by showing that is a vertex cover of . Consider an edge in . By definition of the permutation graphs, and appear in reversed order in and . Since is obtained from (resp., ) by moving symbols in (resp., ), at least one of and must be moved in one of the two permutations. Hence, at least one of and belongs to , showing that is a vertex cover of .
The lemma follows by exhaustively removing elements from upon whose removal all edges are still covered.
Such a vertex cover indeed suffices to find a suitable vertex as required for Lemma 11.
Lemma 15.
Let , . Let and be consistent -fitting colorings of and w.r.t. some permutation with and . Consider an inclusion-wise minimal vertex cover of with for a pair of witnesses for and . Then in time we can find a symbol with . The computation does not require the sets and as input.
Proof.
Observe that can be transformed into by deleting and reinserting the symbols in , so implies that . As , we have that there is a symbol such that . As and are consistent -fitting, we have that and . It suffices to consider any such colored symbol , as implies and thus, by we have . With this, we are ready to forge our central tool:
Lemma 16.
Let , and be two permutations with . There exists a set of permutations satisfying
-
the size of is bounded by ; and
-
for each permutation with and , contains a permutation that is one step closer to than , i.e., .
Furthermore, such a set can be computed in time.
Proof.
We compute a collection of pairs of -colorings of according to Lemma 13. For each with and , there exists a consistent -fitting pair of colorings w.r.t. . Thus, for each pair in we perform the following procedure, adding permutations to as we go along.
Based on Observation 10, we can assume that both and have at most red symbols in each block (if not, we recolor some blocks blue accordingly). We list all inclusion-wise minimal vertex covers of that have size at most . We can do so by a simple and well-known branching technique: Start with an empty cover, iteratively take any uncovered edge and create two branches where you add or to the vertex cover, respectively, and repeat this procedure times (or until all edges are covered). This list of at most covers may contain some that are not inclusion-wise minimal, but these can be filtered out in time .
By Lemma 14 and as every witness for or has size at most , at least one of the listed vertex covers consists only of vertices in , where and are witnesses for the respective colorings. This holds true for every permutation for which the current colorings are consistent -fitting. Using Lemma 15 on each of the vertex covers, we obtain a set of at most symbols, and for every suitable at least one of these symbols is included in for respective witnesses. We note that applying Lemma 15 to vertex covers containing vertices which do not stem from union of witnesses might yield incorrect symbols, but for each of the vertex covers we still add at most one symbol. We apply Lemma 11 to each of the symbols, thereby producing a set of permutations, which we all add to . Note that the lemmas guarantee that for every for which the colorings are consistent -fitting, we added at least one permutation which is one step closer to than the current candidate .
The final size of is bounded by
The runtime estimate is based on combining the size of from Lemma 13 with the time to find the unique vertex cover respecting a given pair of colorings. All other steps, like processing the blocks, are asymptotically dominated by that time. There are at most pairs of colorings to enumerate. For each pair, the branching procedure on the vertex covers takes time as and the existence of a vertex cover of size implies that . Thus, the total time to compute is in
Now we are ready to prove Theorem 2.
Theorem 2. [Restated, see original statement.]
Ulam Metric -Center can be solved in time, where and .
Proof.
We may assume without loss of generality that any YES-instance admits a solution with exactly centers. Indeed, if a solution exists with fewer than centers, we can always add arbitrary permutations as centers until we reach exactly centers. In addition, we exclude the trivial YES-instances where . Now, consider a hypothetical solution consisting of centers. For each , let the th cluster be the set of permutations in with distance at most to . If a permutation would fit into multiple clusters, we assign it to only one of them arbitrarily.
We describe our algorithm as a branching procedure. It maintains a candidate set of size at most along with a budget for each candidate . Here, is intended to evolve into a solution to the Ulam Metric -Center instance, and each budget indicates how many modifications to remain (or have been used so far). In each branch, the algorithm checks whether the current candidate set covers all permutations in within distance . The algorithm halts and accepts the instance if and only if at least one branch finds a valid solution. We now describe the procedure in detail; see Algorithm 1 for a high-level overview.
In the course of the algorithm, we one by one initialize each candidate as a permutation from , and evolve it into the th center. Initially, pick the permutation and set the first candidate to equal this permutation: . Then, the algorithm adds it as the first candidate to and initializes its budget as .
Next, the algorithm branches on a permutation that has distance more than to each of the candidates in . If there is none, then the current candidates form a solution, and we accept the instance. Otherwise, the permutation either belongs to one of the existing clusters or to a new cluster.
-
Existing cluster: For each candidate with remaining budget and distance at most to , we consider the case where belongs to the th cluster. We invoke Lemma 16 with , guide , and to obtain the set of permutations. For each permutation , we create a new branch where we replace by and decrease its budget by one.
-
New cluster: If , we create a branch where belongs to a new cluster. Specifically, we let as a new candidate, initialize its budget as , and add it to .
If none of the two above cases applies, we reject the branch. We accept the instance if and only if at least one branch accepts it. If none of the branches accepts the instance, we reject the branch.
Observe that if the algorithm accepts an instance, it indeed finds a solution. Conversely, consider a YES-instance of Ulam Metric -Center witnessed by some solution . When branching on a permutation not covered by the current candidates , there exists a branch where is assigned to the cluster to which it belongs in . Moreover, when is assigned to the th cluster from the current candidates , by Lemma 16, there is a permutation that is one step closer to than . Thus, in the respective branch, we replace by , moving it one step closer to . Since each candidate starts with the distance at most to its respective center in , after receiving at most updates, it will have converged to that center. From this point on, it will not receive any more updates since there are no permutations assigned to that cluster with a distance of more than . Therefore, there is a branch in which the algorithm finds the solution and accepts the instance.
Finally, we analyze the running time of the algorithm. Recall that the input of the branching procedure contains a set of candidates along with their budgets . Define the measure of the current input of a branch as
and denote by the worst-case running time of the algorithm on inputs with measure .
Observe that each time we add a new candidate to or modify an existing candidate in , the measure decreases by one. On the one hand, when we add a new candidate to , the size of increases by one while the budget of the new candidate is initialized to . Thus, the measure decreases by and there is at most one such branch. On the other hand, when we modify a candidate to a permutation from , its budget decreases by one while the size of remains unchanged. Thus, the measure decreases by as well, and there are at most such branches by Lemma 16. Moreover, computing takes time in , and the remaining time spend on this iteration is dominated by the computation of all Ulam distances to the current candidates (achievable in time). Therefore, we have the recurrence
Notice that the measure satisfies and the algorithm halts when . Solving the recurrence yields
Observe that
which bounds the total running time by
This shows that Ulam Metric -Center is in by .
We prove that the fixed-parameter tractability of Ulam distance with respect to does not extend to a polynomial kernel via a reduction from a problem on binary strings.
Theorem 3 (). [Restated, see original statement.]
Ulam Metric -Center does not admit a polynomial-sized kernel for the parameter unless .
4 The Complexity of Ulam Metric -Median
This section studies the parameterized complexity of Ulam Metric -Median with respect to the parameters and . We first prove that Ulam Metric -Median is -hard parameterized by but is in for this parameterization. Then we show a polynomial kernel parameterized by both and , implying fixed-parameter tractability for this parameterization.
We first rule out fixed-parameter tractability by alone under established complexity assumptions. We then contrast it with a simple -algorithm for Ulam Metric -Median.
For the hardness result, we give a reduction from Multicolored Clique. An instance of Multicolored Clique consists of a graph with a proper vertex coloring using colors, and asks whether contains a clique of size . The problem is known to be -hard when parameterized by [31]. For clarity, we here describe the reduction and then separately prove that it preserves YES-instances and NO-instances.
Let denote the color set, let be the vertex set of and let be the edge set of , where and . Without loss of generality, we assume that , as instances with smaller values can be solved in polynomial time by brute-force.
We construct an instance of Ulam Metric -Median with . The idea of the reduction is to create one permutation for each edge in . We build the instance in a way such that the existence of a multicolored clique allows the construction of a center permutation such that edges with both endpoints in have small total distance to , while every other edge can take itself as its center. Consequently, the number of centers required is , and the median distance is entirely contributed by the edges inside . It remains to choose a suitable value for .
Formally, let . Furthermore, we define the alphabet as the union of the color set, some -symbols representing the vertices, and some -, -, and -symbols representing the edges:
We have . We first construct a base permutation that starts with alternating between the - and -symbols, followed by the - and the -symbols, and finally the color-symbols:
For each edge with , we introduce a permutation obtained from as follows. Suppose has color and has color . Swap and for each ; move to the right of ; move to the right of ; and move the remaining color-symbols to the right of without changing their relative order. That is,
where . Finally, recall that . We set , and let the set of permutations consist of all permutations for edges in the graph, i.e., .
Lemma 17.
The stated reduction from MultiColoredClique to Ulam Metric -Median preserves YES-instances.
Proof.
Assume that contains a clique of size at least , which contains exactly one vertex of each color. We prove that there is a set of size that is a solution for the Ulam Metric -Median instance . For each vertex , let be the color of . Define to be the permutation obtained from by moving each symbol right after the symbol . (There is no color-symbol after if .) That is, if with , then
We then let , where is the set of permutations associated with an edge that has both endpoints covered by . Observe that and the sum of distances of each permutation to its closest median is at most . Any permutation in can be transformed into by moving the color-symbols that are not yet at the correct position as well as the symbols of the form with . Thus, the total sum of distances is at most .
Lemma 18.
The stated reduction from MultiColoredClique to Ulam Metric -Median preserves NO-instances.
Proof.
We prove by showing that the existence of a solution to the constructed Ulam Metric -Median instance implies the existence of a solution to the MultiColoredClique instance.
Assume the Ulam Metric -Median instance is solved by a set of permutation medians which minimize the sum of distances. Consider the clustering of described by , where we have one cluster per median permutation in and each permutation in is assigned to the cluster of the closest median under Ulam metric (breaking ties arbitrarily). For ease of presentation, we partition the alphabet into two parts: is the set of - and -symbols; and is the set of -, -, and color-symbols. By construction, any permutation in is a concatenation of two substrings and . It is easy to see that for any pair of permutations . We further define and for any cluster in the clustering.
Clearly, there exists a cluster of size at least two as . Consider a cluster of size . We first argue that is the unique cluster of size more than one. Let be its median with optimal total distance to the permutations in . By the optimality of , the center starts with a substring and end with a substring . It is easy to see that for any permutation . This means that we can optimize and independently to minimize the total distance. First, restrict our attention to the - and -symbols. For any pair of permutations , we have as they have swapped the - and -symbols for distinct edges. Thus, we can derive that
Suppose for the contraction that there were clusters () of size at least two with respective medians . Summing over all these clusters yields
which implies that . By the definition of we have
leading to , a contradiction. Hence, we conclude that is the unique cluster of size more than one, which indicates .
Since is a YES-instance, we have is at least
Since and , we derive that
This implies that only color-symbols can be moved from to each permutation in : there are copies of each - and -symbol in and they are ordered the same way in all permutations. Suppose is the set of colors located before in , and let . Recall that each permutation has two of the color-symbols placed before ; one each after the symbols for its incident vertices. Thus, for at most of the permutations in , both of these color-symbols are in . All other permutations have to move at least one of the two symbols, which requires a total of at least units of the budget. Additionally, for each permutation in , all color-symbols after have to be moved, except a total of at most symbols across all permutations. As a result, the total number of required move operations is at least
Combine this with the bound on , and we finally have
Hence, all inequalities above are in fact equalities, which yields and . In other words, all color-symbols are placed somewhere before in . Note further that the budget is only sufficient if for every permutation both color-symbols “incident” to are located between the same substrings of -symbols as in . Hence, the union of all endpoints of the distinct edges described by has size , implying that these edges form a -clique in .
The -hardness of Ulam Metric -Median immediately follows from Lemmas 17 and 18 and the facts that the described reduction can be computed in polynomial time and determines by a computable function of . See 5
We contrast this lower bound by designing a simple -algorithm for Ulam Metric -Median.
Theorem 4 (). [Restated, see original statement.]
Ulam Metric -Median can be solved in time, where and .
Last, we find a polynomial-sized kernel with respect to , which also establishes the fixed-parameter tractability Ulam Metric -Median by . See 6
5 Conclusion
We initiated the study of the parameterized complexity of the Ulam Metric -Center and Ulam Metric -Median problems. Prior to our work, even the parameterized complexity for the case with parameter was unknown for these problems.
It is known [18] that Closest String cannot be solved in time unless the Exponential Time Hypothesis (ETH) fails (we refer to [18] for the formal definition of ETH). Then the Polynomial Parameter Transformation from Theorem 3 implies the same computational lower bound for Ulam Metric -Center. Is it possible to solve Ulam Metric -Center for in time similarly to Closest String?
For Ulam Metric -Median, it is shown that the problem is -hard when parameterized by but is in under the same parameterization. Furthermore, the problem admits a polynomial kernel for the parameterization by both and . The latter result together with an -algorithm implies that Ulam Metric -Median can be solved in time. Is it possible to improve this running time? Similarly to Ulam Metric -Center, we find that this question is interesting even for . Is there a single-exponential (or even subexponential) in algorithm?
References
- [1] Alok Aggarwal and Jeffrey S. Vitter. The input/output complexity of sorting and related problems. Communications of the ACM, 31(9):1116–1127, 1988. doi:10.1145/48529.48535.
- [2] Nir Ailon, Moses Charikar, and Alantha Newman. Aggregating inconsistent information: Ranking and clustering. Journal of the ACM, 55(5):23:1–23:27, 2008. doi:10.1145/1411509.1411513.
- [3] Alexandr Andoni and Huy L. Nguyen. Near-optimal sublinear time algorithms for ulam distance. In Proceedings of the ACM–SIAM Symposium on Discrete Algorithms (SODA), pages 76–86. SIAM, 2010. doi:10.1137/1.9781611973075.8.
- [4] Kenneth J. Arrow. Social Choice and Individual Values. Wiley, 1951. URL: http://www.jstor.org/stable/j.ctt1nqb90.
- [5] 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. doi:10.1016/j.jda.2014.10.002.
- [6] Manu Basavaraju, Fahad Panolan, Ashutosh Rai, M. S. Ramanujan, and Saket Saurabh. On the kernelization complexity of string problems. Theoretical Computer Science, 730:21–31, 2018. doi:10.1016/j.tcs.2018.03.024.
- [7] Nadja Betzler, Michael R. Fellows, Jiong Guo, Rolf Niedermeier, and Frances A. Rosamond. Fixed-parameter algorithms for kemeny rankings. Theoretical Computer Science, 410(45):4554–4570, 2009. Algorithmic Aspects in Information and Management. doi:10.1016/j.tcs.2009.08.033.
- [8] Nadja Betzler, Jiong Guo, and Rolf Niedermeier. Parameterized computational complexity of Dodgson and Young elections. Information and Computation, 208(2):165–177, 2010. doi:10.1016/j.ic.2009.10.001.
- [9] Nadja Betzler, Jiong Guo, Rolf Niedermeier, and Johannes Uhlmann. Parameterized complexity of candidate control in elections and related digraph problems. Theoretical Computer Science, 410:5425–5442, 2009. doi:10.1016/j.tcs.2009.05.029.
- [10] Therese Biedl, Franz-Josef Brandenburg, and Xiaotie Deng. On the complexity of crossings in permutations. Discrete Mathematics, 309(7):1813–1823, 2009. doi:10.1016/j.disc.2007.12.088.
- [11] Leizhen Cai, Siu Man Chan, and Siu On Chan. Random separation: A new method for solving fixed-cardinality optimization problems. In Second International Workshop on Parameterized and Exact Computation (IWPEC), volume 4169 of Lecture Notes in Computer Science, pages 239–250. Springer, 2006. doi:10.1007/11847250_22.
- [12] Diptarka Chakraborty, Debarati Das, and Robert Krauthgamer. Approximating the median under the Ulam metric. In Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 761–775. SIAM, 2021. doi:10.1137/1.9781611976465.48.
- [13] Diptarka Chakraborty, Debarati Das, and Robert Krauthgamer. Clustering permutations: New techniques with streaming applications. In Innovations in Theoretical Computer Science Conference (ITCS), 2023. doi:10.4230/LIPIcs.ITCS.2023.31.
- [14] Diptarka Chakraborty, Syamantak Das, Arindam Khan, and Aditya Subramanian. Fair rank aggregation. In NeurIPS, 2022. URL: http://papers.nips.cc/paper_files/paper/2022/hash/974309ef51ebd89034adc64a57e304f2-Abstract-Conference.html.
- [15] Diptarka Chakraborty, Kshitij Gajjar, and Agastya Vibhuti Jha. Approximating the center ranking under ulam. In Foundations of Software Technology and Theoretical Computer Science, 2021. doi:10.4230/LIPIcs.FSTTCS.2021.12.
- [16] Ronald Christian, Michael R. Fellows, Frances Rosamond, and Arkadii Slinko. On complexity of lobbying in multiple referenda. Review of Economic Design, 11:217–224, 2007. doi:10.1007/s10058-007-0028-1.
- [17] Luís Cunha, Ignasi Sau, and Uéverton S. Souza. On the parameterized complexity of the median and closest problems under some permutation metrics. Algorithms Mol. Biol., 19(1):24, 2024. doi:10.1186/s13015-024-00269-z.
- [18] Marek Cygan, Fedor V. Fomin, Lukasz Kowalik, Daniel Lokshtanov, Dániel Marx, Marcin Pilipczuk, Michał Pilipczuk, and Saket Saurabh. Parameterized Algorithms. Springer, 2015. doi:10.1007/978-3-319-21275-3.
- [19] Debarati Das and Amit Kumar. Breaking the two approximation barrier for various consensus clustering problems. In Proceedings of the ACM–SIAM Symposium on Discrete Algorithms (SODA), pages 323–372. SIAM, 2025. doi:10.1137/1.9781611978322.10.
- [20] Persi Diaconis and R. L. Graham. Spearman’s footrule as a measure of disarray. Journal of the Royal Statistical Society. Series B (Methodological), 39(2):262–268, 1977. URL: http://www.jstor.org/stable/2984804.
- [21] Cynthia Dwork, Ravi Kumar, Moni Naor, and D. Sivakumar. Rank aggregation methods for the web. In Proceedings of the 10th International Conference on World Wide Web (WWW), pages 613–622. ACM, 2001. doi:10.1145/371920.372165.
- [22] Ronald Fagin, Ravi Kumar, and D. Sivakumar. Efficient similarity search and classification via rank aggregation. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 301–312. ACM, 2003. doi:10.1145/872757.872795.
- [23] Henning Fernau, Fedor V. Fomin, Daniel Lokshtanov, Matthias Mnich, Geevarghese Philip, and Saket Saurabh. Social choice meets graph drawing: How to get subexponential time algorithms for ranking and drawing problems. Tsinghua Science and Technology, 19(4):374–386, 2014. doi:10.1109/TST.2014.6867519.
- [24] Nick Fischer, Elazar Goldenberg, Mursalin Habib, and Karthik C. S. Hardness of Median and Center in the Ulam Metric. In Anne Benoit, Haim Kaplan, Sebastian Wild, and Grzegorz Herman, editors, 33rd Annual European Symposium on Algorithms (ESA 2025), volume 351 of Leibniz International Proceedings in Informatics (LIPIcs), pages 111:1–111:17, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2025.111.
- [25] Jens Gramm, Rolf Niedermeier, and Peter Rossmanith. Fixed-parameter algorithms for CLOSEST STRING and related problems. Algorithmica, 37(1):25–42, 2003. doi:10.1007/s00453-003-1028-3.
- [26] Ragesh Jaiswal, Amit Kumar, and Jatin Yadav. Robust-Sorting and Applications to Ulam-Median. In Keren Censor-Hillel, Fabrizio Grandoni, Joël Ouaknine, and Gabriele Puppis, editors, 52nd International Colloquium on Automata, Languages, and Programming (ICALP 2025), volume 334 of Leibniz International Proceedings in Informatics (LIPIcs), pages 100:1–100:19, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ICALP.2025.100.
- [27] Claire Kenyon-Mathieu and Warren Schudy. How to rank with few errors. In Proceedings of the 39th Annual ACM Symposium on Theory of Computing (STOC), pages 95–103. ACM, 2007. doi:10.1145/1250790.1250806.
- [28] Moni Naor, Leonard J. Schulman, and Aravind Srinivasan. Splitters and near-optimal derandomization. In Foundations of Computer Science (FOCS), pages 182–191. IEEE Computer Society, 1995. doi:10.1109/SFCS.1995.492475.
- [29] Timothy Naumovitz, Michael E. Saks, and C. Seshadhri. Accurate and nearly optimal sublinear approximations to ulam distance. In Proceedings of the ACM–SIAM Symposium on Discrete Algorithms (SODA), pages 2012–2031. SIAM, 2017. doi:10.1137/1.9781611974782.131.
- [30] Pavel A. Pevzner. Computational molecular biology: An algorithmic approach. MIT Press, 2000.
- [31] Krzysztof Pietrzak. On the parameterized complexity of the fixed alphabet shortest common supersequence and longest common subsequence problems. J. Comput. Syst. Sci., 67(4):757–771, 2003. doi:10.1016/S0022-0000(03)00078-3.
- [32] Svatopluk Poljak. A note on stable sets and colorings of graphs. Commentationes Mathematicae Universitatis Carolinae, 015(2):307–309, 1974. URL: http://eudml.org/doc/16622.
- [33] Anke van Zuylen and David P. Williamson. Deterministic algorithms for rank aggregation and other ranking and clustering problems. In Approximation and Online Algorithms, pages 260–273. Springer, 2007. doi:10.1007/978-3-540-77918-6_21.
