Manuscript Offprint
arXiv:2609.05874Ulam Rank Aggregation Is Hard to Approximate for Four Rankings
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
We study the approximability of rank aggregation under the Ulam metric. In the Ulam median problem, the goal is to find a ranking (permutation) minimizing the sum of its Ulam distances to the input rankings, while in the Ulam center problem, the objective is to minimize the maximum such distance. We prove that, for every , it is NP-hard to approximate either Ulam median or Ulam center within a factor of , even when the input consists of only four rankings. We further show that unless , neither problem admits a polynomial-time additive approximation scheme. Prior to our work, only the exact versions of both problems were known to be NP-hard, and that too only when the number of input rankings is unbounded [Fischer et al., ESA'25 and Bachmaier et al., J. of Discrete Algorithms'15]. Furthermore, our inapproximability results are optimal in terms of the number of input rankings since for three inputs it is already known to be polynomial-time solvable [Chakraborty, Das, Krauthgamer, SODA'21].
En route, we introduce a new general framework for reducing Boolean constraint satisfaction problems (CSP) to the Ulam median with only four inputs. As a specific instantiation of the reduction framework, we obtain our hardness-of-approximation results. The corresponding hardness for the Ulam center follows from a reduction from the Ulam median.
1 Introduction
Aggregating potentially inconsistent information from multiple sources is a fundamental challenge across social choice, information retrieval, and data analysis. When sources such as voters, search engines, or learned agents provide complete orderings over a set of alternatives, the problem is known as rank aggregation. The goal is to compute a consensus ranking that optimizes a specific objective function. Because different individuals or retrieval systems rarely agree on every pair of alternatives, input rankings inherently conflict. This setting naturally arises in diverse applications, including voting, web search, database systems, similarity search, and classification [8, 15, 19, 16, 1].
Two of the most well-studied optimization objectives in this domain are the median and center variants. The median variant seeks a consensus ranking (permutation) that minimizes the sum of distances to the input rankings, while the center variant minimizes the maximum distance to any
*This paper merges two recent works [18, 3], subsuming and strengthening the results of both. †Pennsylvania State University. Email: sfa6135@psu.edu ‡National University of Singapore. Work partially supported by an MoE AcRF Tier 1 grant (T1 251RES2303) and a Google South & South-East Asia Research Award. Email: diptarka@nus.edu.sg §National University of Singapore. Email: e1583414@u.nus.edu ¶Pennsylvania State University. Work supported in part by NSF grant 2337832. Email: debaratix710@gmail.com ¶Rutgers University. Supported by the National Science Foundation under Grants CCF-2313372 and CCF-2443697. Email: mursalin.habib@rutgers.edu **Pennsylvania State University. Email: tfn5179@psu.edu input. In both cases, the optimal consensus may be any valid permutation, not strictly one of the original inputs. Ultimately, the computational complexity of solving either variant depends heavily on the underlying distance metric used to compare permutations.
In this paper, we study rank aggregation under the Ulam distance. For two rankings of items, their Ulam distance is the minimum number of move operations required to transform one into the other. Equivalently, it is minus the length of their longest common subsequence (LCS), or one-half of their insertion-deletion (edit) distance, thereby retaining the alignment structure of edit distance without repeated symbols. The metric is also natural for rankings: a move models a displaced item while preserving the relative order of a large unaffected subsequence. Accordingly, Ulam distance has been studied extensively in several algorithmic settings [14, 13, 2, 25, 7]. Rank aggregation under the Ulam metric, in particular, has attracted considerable recent attention [10, 12, 11, 21, 9, 5].
For an arbitrary number of input rankings, the Ulam median problem is NP-hard [17] and the best-known polynomial-time approximation factor for Ulam median is 1.968 [9], building on a sequence of earlier advances [10, 11, 21]. The NP-hardness result in [17], however, applies only when the number of input permutations is unbounded, that is, when the number of inputs is part of the instance. It therefore yields no hardness for any fixed number of inputs. At the other end of the spectrum, Ulam median can be solved exactly in polynomial time for three input permutations [10]. Thus, prior to this work, the complexity of the problem remained open for every fixed number of inputs.
This gap is particularly intriguing given the close connection between the Ulam and edit metrics. For the more general median-string problem under insertion-deletion edit distance, where both the input strings and the median may be arbitrary strings, an exact median can be computed in polynomial time for every fixed number of inputs using a standard multidimensional dynamic program [28, 23, 26]. Since the Ulam distance is precisely one-half of the insertion-deletion distance on permutations over a common alphabet, one might expect the additional permutation structure to simplify the median problem. This leads to the following question:
Can the Ulam median be computed exactly in polynomial time for every fixed number of input permutations?
As mentioned earlier, when the number of input rankings is unrestricted, the best-known polynomial-time approximation factor for Ulam median is 1.968. The situation appears more favorable when the number of inputs is fixed. Using the fixed-dimensional dynamic program for edit-distance median as a relaxation and subsequently transforming its output into a permutation yields a polynomial-time approximation factor strictly better than 3/2 for every fixed number of input permutations. In particular, a sharper analysis of the approach of [10] gives a 5/4-approximation for four inputs. For completeness, we present the algorithm and its analysis in Section B.
Further evidence that arbitrarily accurate approximation might be possible comes from the Kendall-tau metric, another standard distance measure on rankings. The median problem under Kendall-tau, also known as Kemeny rank aggregation, is NP-hard already for three input rankings [27, 24], yet admits a polynomial-time approximation scheme (PTAS) even when the number of inputs is unrestricted [22]. Thus, although Ulam median is easier from the viewpoint of exact computation for three inputs, it is natural to ask whether it enjoys a comparable approximation guarantee. This leads to our second question:
Does Ulam median admit a PTAS, at least when the number of input permutations is fixed?
We answer both questions negatively. We prove an explicit constant-factor hardness of approximation for Ulam median with exactly four input permutations, thereby ruling out a PTAS unless P = NP. Together with the exact algorithm for three inputs, this establishes a sharp transition from exact polynomial-time solvability with three inputs to constant-factor inapproximability with four. It also reverses the comparison with Kendall-tau median from the viewpoint of approximation: whereas Kendall-tau median admits a PTAS even for an unrestricted number of inputs, Ulam median admits no PTAS already for four. Thus, despite being easier for exact computation on three inputs, Ulam median is strictly harder to approximate in this precise sense. Finally, our reduction from Ulam median to Ulam center transfers the same inapproximability to the center objective.
Theorem 1.1. For every fixed , it is NP-hard to approximate the Ulam median within a (multiplicative) factor of , even when the input consists of exactly four permutations.
We would like to emphasize that the previously known NP-hardness reduction for the Ulam median requires an unbounded number of input permutations [17]. It starts from MAX-CUT, viewed as a Boolean CSP in which vertices are variables and edges are constraints. It introduces a pair of permutations for every edge, so the number of input permutations depends on the number of constraints. It also uses many auxiliary permutations to ensure that the median encodes a valid cut. These auxiliary permutations dominate the objective and destroy any gap in the source MAX-CUT instance. Consequently, the reduction establishes NP-hardness but does not yield any constant factor hardness of approximation.
In contrast, our reduction uses only two permutations to encode all the constraints and two more to enforce consistency. This keeps the number of input permutations at four while preserving the approximation gap. More generally, we develop a framework that transforms local permutation gadgets for Boolean constraints into gap-preserving reductions to the Ulam median with only four input permutations (see Section 4). The framework allows the same consistency and anchor constructions to be reused across different CSPs. Combining polynomial-time constructible, constant-size labeled gadgets with prescribed LCS scores for satisfying and unsatisfying assignments and globally balanced labels for each variable, we establish an exact relation between the CSP optimum and the Ulam-median optimum. Instantiating this framework with MAX-E3-LIN-2 yields Theorem 1.1.
The same reduction produces a gap linear in the total input length (for input permutations over symbols). This also rules out a polynomial-time additive approximation scheme unless P = NP, even for four input permutations.
Theorem 1.2. For every fixed , it is NP-hard to approximate the Ulam median within an additive -factor with input permutations over an alphabet of size , even when .
Together with the exact polynomial-time algorithm for three input permutations [10], our result establishes a sharp transition from exact tractability with three inputs to constant-factor inapproximability with four. By comparison, the general median-string problem under edit distance can be solved exactly in polynomial time for every fixed number of input strings [28, 23]. This contrast highlights the computational challenges imposed by requiring the median itself to be a permutation, even when the number of inputs is fixed.
The same multiplicative inapproximability bound holds for the Ulam center, ruling out a PTAS unless P = NP, again with only four input permutations.
Theorem 1.3. For every fixed , it is NP-hard to approximate the Ulam center within a (multiplicative) factor of , even when the input consists of exactly four permutations.
Previously, the Ulam center was known to be NP-hard only when the number of inputs is unrestricted [4]. On the algorithmic side, it admits an exact polynomial-time algorithm for three input permutations and an approximation factor strictly better than 3/2 for every fixed number of inputs [12]. Our result therefore establishes the same sharp transition from exact tractability with three inputs to constant-factor inapproximability with four. For general strings under edit distance, however, a dynamic program analogous to the one for median strings computes an exact center in polynomial time for any fixed number of inputs. Thus, the hardness caused by the permutation constraint extends beyond the median objective and holds for the center objective as well.
We obtain the hardness for the center objective through an approximation-preserving reduction from Ulam median to Ulam center that also preserves the number of input permutations. Consequently, any improvement to the multiplicative hardness bound for Ulam median immediately transfers to Ulam center under the same restriction on the number of inputs. The same reduction also rules out a polynomial-time additive approximation scheme for Ulam center unless P = NP, even with four inputs.
Theorem 1.4. For every fixed , it is NP-hard to approximate the Ulam center within an additive -factor with input permutations over an alphabet of size , even when .
1.2 Technical overview
We begin with an overview of the reduction establishing NP-hardness, then explain how its underlying ideas lead to a general framework and our hardness-of-approximation results.
The basic 3-SAT reduction. To illustrate our main techniques, we start with a simplified description of how a 3-SAT formula can be transformed into four permutations whose optimal Ulam median encodes its satisfiability. The key is to view satisfiability as a partition problem: place every literal occurrence on a true side or a false side, so that every clause contains a true occurrence and, for each variable, all positive occurrences lie on one side and all negative occurrences on the other. The latter condition ensures that the partition comes from a single assignment. Thus, our goal is to construct four permutations whose Ulam median encodes this partition problem.
To do so, we start from a balanced 3-CNF formula and introduce a fresh symbol for each literal occurrence (so even two appearances of the same literal in different clauses receive different symbols). Next, we construct two permutations over this alphabet that give a clause score. For a set of proposed true occurrences (which are possibly inconsistent), they satisfy
where by , we mean the string obtained by deleting all symbols outside in . To construct this pair, let denote the three occurrence symbols of clause . In a fixed clause order, concatenates the blocks , while concatenates their reversals . A common subsequence can therefore contain at most one symbol from each clause, and the shared block order lets it contain one from every clause with a symbol in .
Then, we construct two more permutations that give a consistency score, measuring how consistent different occurrences of the same literal are across clauses. For a set of proposed false occurrences, they satisfy
Balanced means that every variable has equally many positive and negative occurrences.
To construct this pair, let and list all negative and all positive occurrences of , respectively, in fixed internal orders. Both permutations list the variables in the same order, using in and in , without changing either block internally. A common subsequence can use symbols from at most one block for each variable, but can retain all selected symbols from that block. After restricting to , choosing the block with more remaining symbols corresponds to setting so that as many of its selected occurrences as possible are false, yielding the stated consistency score. Since the formula is balanced, every assignment makes exactly half of all occurrences false. This is therefore an upper bound on the consistency score, attained by the false side of any consistent partition. Figure 1 illustrates the two mechanisms: reversing the occurrence order within each clause block and swapping the blocks of positive and negative occurrences for each variable.


Figure 1: The two local mechanisms in the 3-SAT reduction. (a) The three occurrence symbols of each clause appear in reverse order, while the clause blocks retain their order. Restricting to gives one LCS match for each clause meeting . (b) For each variable , the negative-occurrence block and the positive-occurrence block swap places, retaining their internal orders. Restricting to contributes the larger of the two label-class sizes. Solid connections illustrate one admissible choice in each panel.
Finally, we take a long anchor block of fresh auxiliary symbols and form the four input permutations
Our anchor-block lemma (Lemma 3.3) shows that, when is sufficiently long, some optimal median has the form , where and order the symbols in a partition of the literal occurrences (see Figure 2 for an illustration). We interpret the symbols before as proposed true occurrences and those after it as proposed false occurrences. This partition need not be consistent. After optimizing the order within each side, we show that the total LCS score depends on the sum of the clause score of and the consistency score of . Thus, an optimal median must choose a partition maximizing the sum of these two scores.
The partition induced by a satisfying assignment attains the maximum possible sum: the clause score counts every clause, and the consistency score counts exactly half of all occurrences. Conversely, attaining both bounds yields a satisfying assignment. Thus, the optimum median cost determines whether is satisfiable, proving NP-hardness even with four input permutations.
In fact, the reduction is also gap-preserving. An optimal median corresponds to a partition, not necessarily consistent, that maximizes the sum of the clause score on the proposed true side and the consistency score on the proposed false side. We show that inconsistent partitions never help: any extra clause score obtained by placing incompatible literal occurrences on the proposed true side is offset by a loss in the consistency score. The key is a quantitative decoding argument: for each variable, choose the value that makes as many of its occurrences in true as possible, breaking ties arbitrarily, and let count selected occurrences that remain false. The clause score can exceed the number of clauses satisfied by this assignment by at most , while balance makes the consistency score exactly , where is the total number of literal-occurrence symbols. Thus, the decoded assignment induces a consistent partition with at least the same combined score, allowing the four input permutations to preserve the source gap. Figure 2 summarizes how decoding bounds its combined score.
Combining this with the fact that MAX-3-SAT is NP-hard to approximate to any factor better than 7/8 gives hardness of approximation within every fixed factor smaller than 53/52, even with exactly four input permutations. The details appear in Section 3.

Figure 2: From four input permutations to a partition, and from an arbitrary partition to a consistent assignment. Here is the number of literal-occurrence symbols, is the clause score, and is the consistency score. For the majority assignment , with ties broken arbitrarily, let count occurrences in that are false under . Any extra clause score is at most , while the consistency score loses exactly . Thus, inconsistent partitions cannot improve the combined score.
A general framework and stronger hardness. Looking back at the proof above, one may see that the only part of the reduction specific to 3-SAT is the pair of clause permutations . It is therefore natural to ask whether we can replace them by permutations for a different Boolean constraint. We show that this is indeed possible. More precisely, we associate each symbol with a variable and a Boolean label. For 3-SAT, the label records whether a literal occurrence is positive or negative, or equivalently, the value that makes the literal true. In general, the label should be interpreted as the value that the symbol wants its associated variable to take. It then suffices to find, for each constraint, a pair of local permutations whose score on the symbols agreeing with a proposed local assignment is large exactly when the constraint is satisfied. More precisely, each constraint must admit a polynomial-time constructible pair of permutations on labeled symbols whose restricted LCS is exactly for every satisfying local assignment and exactly for every unsatisfying one, for fixed constants , and common to all constraints. The preceding argument – that any gain in the constraint score from inconsistent choices is offset by a loss in the consistency score – extends beyond 3-SAT. Its key ingredient is gadget-independent: deleting the same symbols from both restricted permutations decreases their LCS by at most , regardless of the internal structure of the local constraint gadgets. Assuming that each variable has equally many symbols of each label overall, the consistency and anchor gadgets can be reused, and the same argument controls inconsistent partitions. The resulting hardness factor obtained from the reduction depends both on the gap of the starting CSP and on the quality of these local gadgets.
We instantiate this framework with MAX-E3-LIN-2. We first construct a pair of balanced eight-symbol permutations and whose restricted LCS is three when the equation is satisfied and two otherwise. For an equation , the gadget in Figure 3 uses two copies of each label for and one copy of each label for and , so every assignment selects four symbols and the gadget is balanced for each variable. The two selected -symbols appear on either side of the selected - and -symbols in one permutation and are consecutive in the other, preventing all four symbols from forming a common subsequence. Their placement encodes parity: a satisfying assignment puts the selected - and -symbols on the same side of the consecutive -pair, in the same order in both permutations, so they can be matched together with one -symbol. An unsatisfying assignment produces two disjoint reversed pairs, forcing every common subsequence to omit at least one symbol from each pair and limiting the LCS to two. Flipping the labels of the -symbols handles , interchanging the parity classes while preserving balance. We then use the fact that MAX-E3-LIN-2 is hard to approximate beyond , which is substantially stronger than the guarantee for 3-SAT. Combining the gadget with this larger source gap improves the hardness bound to every fixed factor smaller than 35/34. The framework and its instantiation appear in Sections 4 and 5.

Figure 3: The eight-symbol parity gadget for . For the indicated local assignment , the four symbols in are the ones whose labels (indicated as subscripts) agree with and shown with solid borders; the other four disagreeing symbols are gray and dashed. Teal nodes and connecting lines exhibit a longest common subsequence of the restrictions to : in the unsatisfied example and in the satisfied example. In general, the restricted LCS has length 2 for every unsatisfying assignment and length 3 for every satisfying assignment.
Median hardness to center hardness. To transfer the hardness results to Ulam center, we use the cyclic block reduction from median to center for the Kendall-tau metric [6], whose applicability to the Ulam metric was observed in [12]. These works focus on polynomial-time reductions sufficient
The constraints are linear equations over , each involving three distinct Boolean variables; the goal is to maximize the number of satisfied equations.
for establishing NP-hardness, rather than explicitly formulating the approximation-preservation guarantees needed here. Given a Ulam median instance with input permutations over symbols, we create disjoint copies of its alphabet and construct center inputs over symbols. All inputs use the same order of the alphabet copies, while the original permutations are arranged cyclically across them. Thus, every center input contains one copy of each original permutation, and every original permutation appears once in each block across the center instance.
Placing the same median candidate in every block makes its distance to each center input equal to its total distance in the original median instance. Conversely, the common block order lets us rearrange any center candidate blockwise without increasing its radius. Averaging over the center inputs then shows that at least one block defines a median candidate of cost no larger than that radius. These observations establish the exact preservation of the optimum value and the lossless extraction of a median solution from any center solution (see Lemma 6.1). Together with the preservation of the number of inputs and the alphabet size of in the center instance, these guarantees transfer both multiplicative and additive hardness from the Ulam median to the Ulam center. For completeness, we provide a detailed proof of these guarantees in Section C.
2 Preliminaries
Notations. For , we use to denote the set . We use the notation to denote the union of two disjoint sets. For any set partitioned into disjoint subsets , we thus write .
Permutations and Ulam distance. For an alphabet , let denote the set of all permutations of . For a permutation and a subset , let denote the restriction of to the symbols in , with their relative order preserved. For two sequences and , let denote the length of a longest common subsequence. For any two , their Ulam distance is
We will repeatedly use the following elementary identity, which follows from the triangle inequality for the Ulam distance.
Lemma 2.1. Let be an alphabet and let . Then
Proof. Let . For every , the triangle inequality for Ulam distance gives
Using the definition of the Ulam distance between any two permutations , and rearranging, we obtain
This upper bound is attained by taking , since . The claimed equality follows.
Ulam median. An instance of Ulam median is a (multi)-set of permutations of a common alphabet . The problem asks to find a permutation that minimizes the total distance to input permutations, namely, . We denote the optimum value of the instance by
Ulam center. An instance of Ulam center is a (multi)-set of permutations of a common alphabet . The problem asks to find a permutation that minimizes the radius . We denote the optimum value of the instance by
Approximation scheme. For the Ulam median problem, an algorithm is a polynomial-time approximation scheme (PTAS) if, given any constant and an instance of permutations over an alphabet of size , it computes in polynomial time a solution satisfying . An algorithm is an -additive approximation scheme for the Ulam median problem if it outputs a solution in polynomial time such that . The definition of PTAS for Ulam center is analogous to that of the median problem. An algorithm is an -additive approximation scheme for the Ulam center problem if it outputs a solution in polynomial time such that .
Max-E3-Lin-2. An instance of MAX-E3-LIN-2 is a Boolean CSP , where is a set of Boolean variables and is a list of equations over . Each equation has the form
where are distinct variables and . For an assignment , let
and define
We use the following gap form of Håstad's hardness theorem.
Theorem 2.2 (Håstad [20, Theorem 5.4]). For every fixed , it is NP-hard to distinguish instances of MAX-E3-LIN-2 with equations between the following two cases:
• (Completeness) .
• (Soundness) .
3 The Basic 3-SAT Reduction
In this section, we give a direct reduction from 3-SAT to Ulam median on four input permutations. Let
be a 3-CNF formula on the variable set . We assume that every clause contains exactly three literal occurrences, and that, for every variable , the number of positive occurrences of equals the number of negative occurrences of . For an assignment to the variables, let
These assumptions do not affect our results; see Section A.
denote the number of clauses satisfied by , and define
Our construction will contain one symbol for each literal occurrence in . In particular, two appearances of the same literal will correspond to distinct symbols. Let denote the set of all such literal-occurrence symbols, and let .
For a symbol , let denote the variable underlying that literal occurrence. We associate with a label , defined to be the value of that makes the corresponding literal true. In other words, a positive occurrence of has label 1, while a negative occurrence of has label 0.
For every variable and , define
Since every variable has an equal number of positive and negative occurrences, we have
For each variable , write , so that . For each clause , let denote the set of its three literal-occurrence symbols. A central concept in our discussion is that of a truth partition, which we now define.
Truth partitions. We refer to any partition as a truth partition, interpreting and as the proposed sets of true and false literal occurrences. A truth partition is consistent if, for every variable , there exists such that
In other words, a consistent partition disallows placing occurrences of the same literal on different sides, or occurrences of a literal and its negation on the same side.
Next, we define the agreement set corresponding to an assignment to the variables. For an assignment define
Note that contains precisely the literal occurrences made true by . Thus, induces the consistent truth partition
Under this partition, precisely when satisfies the clause . The balance condition also gives
We are now ready to describe our construction. At a high level, our construction consists of two pairs of permutations. The first pair, which we refer to as the clause-witness gadget, provides a clause score, which records how many clauses are satisfied by a set of proposed true literals. The second pair, which we refer to as the variable-consistency gadget, supplies a consistency score, which records how consistent different occurrences of the same literal are across clauses. For the remainder of this section, fix an arbitrary total ordering of the symbols in .
Clause-witness gadget. For each clause , let be the string obtained by listing the three symbols in according to the fixed ordering of . Let denote its reversal, and define
The basic property of this gadget is : a common subsequence may contain at most one symbol from each clause and may choose one symbol from every clause. We will use the following stronger form where we restrict to an arbitrary subset of all literal occurrences.
Lemma 3.1. For every ,
Proof. For every , the relative order of the symbols in is reversed between and . Therefore, a common subsequence of and contains at most one symbol from . Hence
Conversely, for every such that , choose one symbol from this intersection. Since the clause blocks occur in the same order in and , the chosen symbols, listed in increasing order of , form a common subsequence. This proves the reverse inequality and hence the claimed equality.
Variable-consistency gadget. For every variable and , let be the string obtained by listing the symbols in according to the fixed ordering of . Define
For each variable, the two label blocks appear in opposite orders in and . Consequently, a common subsequence can use symbols from at most one label class of each variable.
Lemma 3.2. For every ,
Consequently, .
Proof. Fix . Every symbol of precedes every symbol of in , while every symbol of precedes every symbol of in . Therefore, a common subsequence contains symbols from at most one of these two blocks. Its contribution from the blocks for is consequently at most .
This bound can be attained simultaneously for every variable: for each , choose the larger of and , list its symbols in their common internal order, and concatenate these choices in variable order. This proves the formula. The upper bound follows from
Adding an anchor block. Let be an alphabet disjoint from , where , and define
We refer to Z as the anchor block and its symbols as anchor symbols. Finally, construct the four input permutations
and let
The following lemma shows that the anchor block acts as a separator: every candidate median may be transformed, without decreasing any of its four LCS scores, into one in which Z appears as a contiguous block.
Lemma 3.3 (Anchor-block lemma). Let be arbitrary permutations of . For every permutation of , there exist a partition and permutations of , respectively, such that satisfies
for each .
We defer the proof of Lemma 3.3 to Section 3.1. Note that this lemma is independent of the 3-SAT instance : it applies to any four permutations of . It allows us to restrict attention, without loss of generality, to only candidate medians of the form . Each such “canonical” permutation induces a truth partition , where and are the symbols placed before and after , respectively. We interpret as the proposed set of true literal occurrences and as the proposed set of false literal occurrences. Note that this truth partition need not be consistent. Once the partition is fixed, the only remaining choice is the ordering of the symbols within and .
Lemma 3.4 (Fixed-partition optimum). Fix a partition . Then
where the maximum ranges over all permutations of and of .
Proof. Let . Since , a longest common subsequence of and cannot contain a symbol from : any such subsequence contains no anchor symbol and therefore has length at most , whereas itself is a common subsequence of length . Hence
Symmetrically,
Applying Lemma 2.1 independently on the two sides gives
These maxima are attained by and , respectively. Adding the equalities and using proves the lemma.
For , the expressions and are important enough to give them names. We call them the clause score and consistency score, respectively, and write
The names are suggestive, as counts the clauses containing an occurrence from , while is the maximum number of occurrences in that can simultaneously evaluate to false under a single assignment.
Now, since every input permutation has length , Lemmas 3.3 and 3.4 give
In other words, an optimal median must correspond to a truth partition, not necessarily consistent, that maximizes the sum of the clause score of the proposed true side and the consistency score of the proposed false side. We will show that inconsistent partitions never help—any extra clause score obtained by placing incompatible literal occurrences on the proposed true side is offset by a loss in the consistency score.
We are now ready to prove the main guarantee of our construction.
Theorem 3.5. The instance satisfies
Proof. By (3), it suffices to prove that
First, let be an assignment satisfying clauses, and consider its induced truth partition
By Lemmas 3.1 and 3.2 and the balance condition,
This proves .
For the reverse inequality, fix an arbitrary truth partition . The symbols in are being treated as true, but they need not be simultaneously true under any assignment. We therefore choose an assignment that makes as many of these proposed true occurrences as possible actually true. This can be done independently for each variable: choose
breaking ties arbitrarily. Let
Thus, counts the occurrences placed on the proposed true side that nevertheless evaluate to false under .
We first compare the clause score with the number of clauses satisfied by f. By Lemma 3.1,
A clause counted by but not satisfied by must contain one of the false occurrences in . Since each literal occurrence belongs to exactly one clause, there are at most such clauses. Therefore,
In other words, the proposed partition can gain at most clause witnesses beyond those justified by the decoded assignment.
We now show that these disagreements cost exactly in the consistency score. Fix a variable . By the choice of and (1),
Thus, is a largest label class inside . By Lemma 3.2,
This sum counts precisely the occurrences in that evaluate to false under . By balance, exactly literal occurrences evaluate to false in total. Of these, exactly lie in , and all the others lie in . Hence
Combining Equations (4) and (5), we obtain
Thus, the consistent partition induced by has combined score at least as large as that of the original partition: any additional clause witnesses are paid for by the loss in the consistency score. This proves the required upper bound. Applying (3) and using completes the proof.
In particular, Theorem 3.5 gives
Each input permutation has length , and the construction can be carried out in polynomial time. This completes the reduction from 3-SAT. Lemma A.1 immediately yields that Ulam median is NP-hard already at four input permutations.
Approximation hardness. Theorem 3.5 further allows us to transfer approximation hardness for MAX-3-SAT to Ulam median. We use the balanced gap result established in Lemma A.2: for every fixed , it is NP-hard to distinguish formulas satisfying the assumptions above for which from those for which . Applying Theorem 3.5 gives the following gap for Ulam median.
Corollary 3.6. For every fixed , given a four-permutation Ulam-median instance , in which each input permutation has length , it is NP-hard to distinguish between the following two cases.
• (Completeness)
• (Soundness) .
Proof. In the completeness case, Theorem 3.5 gives
In the soundness case, the same theorem gives
□
Note that the ratio between the soundness and completeness thresholds approaches as . We thus obtain the following consequence.
Corollary 3.7. For every fixed , it is NP-hard to approximate Ulam median within a factor of , even when the input consists of exactly four permutations.
Proof. Fix , and set . Choose sufficiently small that
On a completeness instance from Corollary 3.6, a -approximation algorithm would return a permutation of cost strictly less than . On a soundness instance, every permutation has cost at least . Such an algorithm would therefore distinguish the two cases, proving the claim.
3.1 Proof of the Anchor-Block Lemma
In this section, we give a proof of the anchor block lemma.
Proof of Lemma 3.3. Fix an arbitrary permutation of . We transform into the desired canonical form in two steps.
Step 1: sorting the anchor symbols. Let be obtained from by permuting only the symbols of so that they occur in the order . The symbols of remain in their original locations and hence retain their relative order. We claim that, for each ,
For , let denote the number of symbols from that precede in . Since the reordering does not change the locations occupied by symbols of , the anchor symbols preceding in are precisely , while those following are precisely .
Fix , and let be a longest common subsequence of and . If contains no symbol of , then , whereas is a common subsequence of and of length .
Otherwise, let be the last symbol of appearing in . Since every symbol of precedes every anchor symbol in , all anchor symbols appearing in must follow in . Hence contains at most anchor symbols. Moreover,
is a common subsequence of and . Its length is at least , and therefore
The proof for is symmetric. Thus,
It therefore suffices to consider the case in which the anchor symbols occur in the order . We may then write
where each is a possibly empty string over .
Step 2a: analyzing . Fix . We claim that
Indeed, for any , a common subsequence of and can be followed by . Hence
For the reverse inequality, let be any common subsequence of and . If contains no symbol from , then , which is bounded by the right-hand side of Equation (6) by taking .
Otherwise, suppose that the last symbol of appearing in belongs to . Then is a common subsequence of and . Moreover, every symbol of appearing in must belong to , so contains at most such symbols. Therefore,
This proves Equation (6).
Since has length , we have . Thus, when , the quantity inside the maximum in Equation (6) is negative, whereas for it is nonnegative. Consequently, the maximum is attained for some .
It follows that, for each , there exists a longest common subsequence of and whose symbols from all belong to .
Step 2b: analyzing . A symmetric argument gives
Since has length , we have . Thus, if , then the quantity inside the maximum in Equation (7) is negative, whereas for it is nonnegative. Consequently, the maximum is attained for some . Since , we have .
It follows that, for each , there exists a longest common subsequence of and whose symbols from all belong to .
Step 2c: constructing the canonical permutation. Let be the set of symbols appearing in , and let . Define
and set
We show that satisfies all four inequalities in the statement of the lemma.
Fix , and let be a longest common subsequence of and whose symbols from all belong to , as guaranteed by Step 2a. Set . The string is a subsequence of both and , since the construction of preserves the relative order of all symbols in . It follows that is a common subsequence of and . Moreover,
because contains at most symbols from . Therefore,
Similarly, let be a longest common subsequence of and whose symbols from all belong to , as guaranteed by Step 2b, and again set . The string is a subsequence of both and . Consequently, is a common subsequence of and , and
Hence
Finally, Step 1 established that sorting the symbols of does not decrease any of the relevant LCS lengths. Thus, for each ,
This proves the lemma.
□
4 A General Framework for Boolean CSPs
In this section, we give a general framework for reducing arbitrary Boolean CSPs to Ulam median. While reading Section 3, a careful reader might notice that the clause-witness gadget is the only part of the construction that uses the form of a 3-SAT clause. The consistency gadget uses only the variables and labels attached to the symbols, and the anchor-block lemma does not refer to the 3-SAT formula at all. It is therefore natural to ask whether we can replace the clause-witness gadget by one for a different Boolean constraint. Given a general constraint, the key ingredient is a pair of local permutations whose score, when restricted to the symbols agreeing with an assignment, is large exactly when the constraint is satisfied by the assignment. As we show below, such a gadget, together with the same balance assumption, is enough for the reduction to go through.
Let be a Boolean CSP instance, where and . For an assignment , let
and define
Local constraint gadgets. For each constraint , let denote its variables, and let be a fresh alphabet of symbols, where is a fixed positive integer. The alphabets are pairwise disjoint, and we write
Each symbol is associated with a variable and a label . As before, a symbol agrees with an assignment when its associated variable is assigned its label. For a local assignment , define
We require two permutations whose score on this agreement set is large if and only if is satisfied. More precisely, we want constants and , independent of , such that, for every local assignment ,
We refer to as the size of the local gadget and to as its gap. We assume that the labeled alphabets and the local permutations can be constructed in polynomial time from the CSP instance.
The clause-witness gadget from Section 3 is an example of such a local constraint gadget. It has , , and .
Global balance. For the consistency calculation from the 3-SAT proof to go through, we impose the same balance condition. For a variable and , define
and require
Write , so that .
As before, for a global assignment , its agreement set is
and the balance condition gives
Thus, the total number of symbols agreeing with an assignment, and the total number disagreeing with it, are independent of the assignment.
Constraint-checking permutations. To make the local scores add, we place the constraint alphabets in the same order in both permutations:
Lemma 4.1. For every ,
In particular, for every assignment ,
Proof. Let , and let be a common subsequence of and . For each , let . Then is a common subsequence of and . Hence
Conversely, the blocks occur in the same order in both permutations, so concatenating a longest common subsequence from each block attains the right-hand side.
For an assignment , we have . Applying (8) in each block and summing gives the second equality.
Consistency and anchor gadgets. We reuse the variable-consistency permutations from Section 3. For each and , let list the symbols of in a fixed order, and define
The proof of Lemma 3.2 applies unchanged, giving
for every . In particular, the symbols disagreeing with an assignment form one full label class for each variable. By global balance,
Let be an alphabet disjoint from , where , and let . As before, define
and let the set of input permutations be
By Lemma 3.3, we may restrict attention, without loss of generality, to candidate medians of the form , inducing a partition . In the 3-SAT construction, was the proposed true side. Here, it is the proposed agreement set, while is the proposed disagreement set. A partition induced by an assignment has
As before, write
for the constraint and consistency scores, respectively. The proof of Lemma 3.4 applies unchanged, so for each fixed partition,
Since each input permutation has length , this gives
just as in (3).
The local gadget condition determines , but a proposed agreement set need not arise from an assignment. To compare its score with that of an assignment, we will delete the selected symbols that disagree with the assignment. The following lemma bounds the score lost in doing so. It replaces the clause-witness counting argument in the proof of Theorem 3.5.
Lemma 4.2. Let be permutations of the same alphabet and let be two subsets of that alphabet. Then
Proof. Let be a longest common subsequence of and . Deleting all symbols in removes at most symbols and leaves a common subsequence of and . Hence
which proves the claim.
We can now repeat the comparison between an arbitrary partition and a partition induced by an assignment.
Theorem 4.3. The instance satisfies
Proof. By (14), it suffices to prove that
First, let attain , and take
By Lemma 4.1 and (12),
This proves the lower bound on the maximum combined score.
For the reverse inequality, fix an arbitrary partition . Following the proof of Theorem 3.5, we choose an assignment that agrees with as many symbols of as possible. Thus, for each , choose
breaking ties arbitrarily, and let
The quantity counts the selected symbols that disagree with the decoded assignment.
Apply Lemma 4.2 to the global permutations , with and . Together with Lemma 4.1, this gives
It remains to account for these disagreements in the consistency score. For each variable , the choice of and global balance give
Consequently, (11) and (10) give
The possible excess in the constraint score is therefore offset by the consistency loss. Combining Equations (15) and (16), we obtain
This proves the upper bound on the maximum combined score. Substituting into (14) and using proves the theorem.
Approximation hardness. Theorem 4.3 shows that a gap for the source CSP yields a gap for the resulting Ulam-median instance. More precisely, suppose that, for fixed parameters and constants , it is NP-hard to distinguish such instances for which from those for which . Then Theorem 4.3 gives the following.
Corollary 4.4. Under the preceding assumptions, given a four-permutation Ulam-median instance , in which each input permutation has length , it is NP-hard to distinguish between the following two cases.
Consequently, it is NP-hard to approximate the Ulam median within any fixed factor satisfying .
Proof. The gap follows directly from Theorem 4.3. On a completeness instance, an assignment f satisfying at least cm constraints has
Hence
For any in the stated range, a -approximation algorithm would return a permutation of cost strictly less than on a completeness instance. On a soundness instance, every permutation has cost at least this threshold. Such an algorithm would therefore distinguish the two cases.
Taking the clause-witness gadget and the balanced MAX-3-SAT gap recovers Corollary 3.7. More generally, a stronger source CSP gap alone does not necessarily give a stronger Ulam-median hardness factor. The local gadget must also realize the predicate efficiently: what matters is the gap relative to the fixed overhead .
5 An Instantiation for Max-E3-Lin-2
We now instantiate the framework of Section 4 for the problem MAX-E3-LIN-2. The main motivation for switching from 3-SAT to MAX-E3-LIN-2 is that the latter allows us to assume a much larger gap. Furthermore, we will show that MAX-E3-LIN-2 admits efficient local gadgets as well. Both of these factors will contribute to ultimately obtaining a 35/34 factor hardness of approximation for Ulam median, surpassing the 53/52 factor hardness from Section 3.
Let be an instance with equations over , each of the form
where are distinct variables. We keep the notation and from the previous section. The main contribution of this section is an eight-symbol local gadget that satisfies the conditions required by the framework.
The local gadget. Fix an equation
We now describe the local permutations for this equation. The permutations will make use of the following eight symbols
Here, the four -symbols are associated with , the two -symbols with , and the two -symbols with . Next, we assign labels to these symbols. For and , we set
In other words, the label of a symbol is always equal to its subscript unless the right-hand side of the equation equals zero, in which case the labels of only the -symbols are flipped. Define
Lemma 5.1 (Local parity gadget). For every local assignment ,
Moreover, for each variable in , the gadget contains equally many symbols of label 0 and of label 1.
Proof. Fix some local assignment and write .
Now, among the symbols associated with , each label occurs twice. Among those associated with or with , each label occurs once. This holds for either value of , proving the balance assertion.
Next, we prove the LCS claim. There are two cases, and both involve verification by hand. First, suppose that . Then we have
Number these four symbols 1, 2, 3, 4 in their order of appearance in , and let be the permutation of [4] recording their order in . A common subsequence corresponds exactly to an increasing subsequence of , so
Depending on the values of , we have
| LIS( ) | ||
|---|---|---|
| 000, 011, 101, 110 | 2143 | 2 |
| 001 | 2314 | 3 |
| 010 | 1423 | 3 |
| 100 | 3124 | 3 |
| 111 | 1342 | 3 |
Inspecting the table, we can see that when , the LCS is 3 if and only if , i.e., exactly when the local assignment satisfies equation . If it does not satisfy the equation , the LCS is 2.
If b = 0, then we have
Proceeding exactly as above, we obtain
| LIS( ) | ||
|---|---|---|
| 001, 010, 100, 111 | 2143 | 2 |
| 000 | 3124 | 3 |
| 011 | 1342 | 3 |
| 101 | 2314 | 3 |
| 110 | 1423 | 3 |
Once again, we see that the LCS is 3 if and only if the local assignment a satisfies the equation , otherwise it is 2. This completes the proof.
Corollary 5.2. Let be the instance obtained from the above gadgets by the construction of Section 4. Its four input permutations have length , and
Proof. By Lemma 5.1, the local score condition holds with
Summing the local balance equalities over the constraints containing each variable gives (9). The labeled gadgets can be constructed in polynomial time, so Theorem 4.3 gives the claimed identity. The common permutation length is .
Approximation hardness. We now combine Håstad's gap theorem with the local gadget above to obtain our main hardness result.
Theorem 1.1. For every fixed , it is NP-hard to approximate the Ulam median within a (multiplicative) factor of , even when the input consists of exactly four permutations.
Proof. Fix . For any fixed , Theorem 2.2 gives a source gap with
The local gadget has
Therefore, Corollary 4.4 implies hardness within every factor strictly smaller than
and we may choose sufficiently small that this ratio is greater than . This proves the theorem.
We next show that the same gap rules out an additive approximation scheme.
Theorem 1.2. For every fixed , it is NP-hard to approximate the Ulam median within an additive -factor with input permutations over an alphabet of size , even when .
Proof. Fix , and suppose that there is a polynomial-time algorithm for Ulam median with additive error at most . Given any instance of MAX-E3-LIN-2 with equations, construct the corresponding Ulam-median instance . It consists of permutations over an alphabet of size . Since , the additive error is at most
Now, choose sufficiently small that
In the completeness case of Theorem 2.2, we have . Hence Corollary 5.2 gives
and the algorithm returns a permutation satisfying
In the soundness case, , and therefore every permutation satisfies
By (18), . Thus, the cost returned by the assumed algorithm distinguishes the completeness and soundness cases of Theorem 2.2, a contradiction.
6 Hardness of Approximation for Ulam Center
We now reduce Ulam median to Ulam center while preserving both the number of input permutations and the optimum value. Together with Theorem 1.1, this yields the claimed hardness of Ulam center.
Theorem 1.3. For every fixed , it is NP-hard to approximate the Ulam center within a (multiplicative) factor of , even when the input consists of exactly four permutations.
We first describe an approximation factor-preserving reduction from the Ulam median problem to the Ulam center problem.
Throughout this section, we use zero-based indexing: the input permutations, center permutations, and alphabet copies are indexed by .
Lemma 6.1 (Median-to-center reduction). There is a polynomial-time algorithm that, given an instance of Ulam median over an alphabet of size , constructs an instance of Ulam center consisting of permutations over an alphabet of size such that . Moreover, from any center solution for of radius at most , one can compute in polynomial time a permutation with .
The reduction is the same as the median-to-center reduction for the Kendall-tau metric [6], and its applicability to the Ulam metric was also observed in [12]. These works focus on polynomial-time reducibility for establishing NP-hardness. For completeness, we provide a detailed proof in Section C that explicitly establishes the cost-preservation guarantees stated above. Now, using the above lemma, we show Theorem 1.3.
Proof of Theorem 1.3. Suppose that, for some , there is a polynomial-time -approximation algorithm for Ulam center with four input permutations. Given any four-input Ulam median instance , apply Lemma 6.1 to construct the four-input center instance . Since the construction preserves the optimum value, we can compute a solution for the Ulam median with
contradicting Theorem 1.1.
Next, we use the same reduction to refute the plausibility of attaining an additive approximation; more specifically, we show the following.
Theorem 1.4. For every fixed , it is NP-hard to approximate the Ulam center within an additive -factor with input permutations over an alphabet of size , even when .
Proof. Assume for contradiction that there exists a polynomial-time -additive approximation algorithm for the Ulam center problem with some . Given an Ulam median instance consisting of four input permutations, each of length , we first construct an Ulam center instance consisting of permutations, each of length . We then run the additive approximation algorithm to obtain a solution . By Lemma 6.1, from , we can compute in polynomial time a solution for the Ulam median problem of the instance , satisfying
contradicting Theorem 1.2.
7 Conclusion
We established explicit constant-factor inapproximability for rank aggregation under the Ulam metric. In particular, unless P = NP, neither Ulam median nor Ulam center admits a PTAS, even when the instance consists of only four input permutations. In establishing these hardness results, we introduced a general reduction framework from Boolean CSPs to Ulam median. Our current instantiation does not optimize the resulting inapproximability factor, and further refinements of the framework may yield stronger bounds.
A natural next step is to narrow the substantial gap between these lower bounds and the best known approximation algorithms. One promising approach is to extend our framework to non-Boolean CSPs, potentially yielding stronger hardness results. Such an extension requires overcoming additional technical obstacles, which we leave as an intriguing open direction. For Ulam center, determining whether one can beat factor 2 when the number of inputs is part of the input remains another compelling open direction.
AI Disclosure. The authors discovered the initial reduction from 3-SAT, establishing NP-hardness for four input permutations. They subsequently used ChatGPT 5.6 Sol to develop an initial hardness-of-approximation result. By inspecting the proof, the authors identified a general reduction framework that is presented in this paper. With further assistance from ChatGPT 5.6 Sol, they then constructed the local gadget used to instantiate this framework to derive the claimed constant factor for the hardness. The authors take full responsibility for the results, proofs, and presentation.
References
[1] Nir Ailon, Moses Charikar, and Alantha Newman. Aggregating inconsistent information: Ranking and clustering. J. ACM, 55(5):23:1–23:27, 2008.
[2] Alexandr Andoni and Huy L. Nguyen. Near-optimal sublinear time algorithms for Ulam distance. In Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2010, pages 76–86, 2010.
[3] Sk Ruhul Azgor, Diptarka Chakraborty, Le Van Cuong, Debarati Das, and Tien Long Nguyen. Hardness of approximation of rank aggregation on ulam metric. arXiv preprint arXiv:2608.29180, 2026.
[4] 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. 24th International Workshop on Combinatorial Algorithms (IWOCA 2013).
[5] 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), pages 19:1–19:23, Dagstuhl, Germany, 2026. Schloss Dagstuhl – Leibniz-Zentrum für Informatik.
[6] Therese Biedl, Franz J Brandenburg, and Xiaotie Deng. On the complexity of crossings in permutations. Discrete Mathematics, 309(7):1813–1823, 2009.
[7] Mahdi Boroujeni and Saeed Seddighin. Improved MPC algorithms for edit distance and Ulam distance. In The 31st ACM on Symposium on Parallelism in Algorithms and Architectures, SPAA 2019, pages 31–40, 2019.
[8] Felix Brandt, Vincent Conitzer, Ulle Endriss, Jérôme Lang, and Ariel D Procaccia. Handbook of computational social choice. Cambridge University Press, 2016.
[9] Amir Carmel, Debarati Das, and Tien-Long Nguyen. A Scalable and Unified Framework to Weighted Rank Aggregation. 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), pages 49:1–49:23, Dagstuhl, Germany, 2026. Schloss Dagstuhl – Leibniz-Zentrum für Informatik.
[10] 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.
[11] Diptarka Chakraborty, Debarati Das, and Robert Krauthgamer. Clustering permutations: New techniques with streaming applications. In 14th Innovations in Theoretical Computer Science Conference (ITCS 2023), volume 251 of Leibniz International Proceedings in Informatics (LIPIcs), pages 31:1–31:24. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2023.
[12] Diptarka Chakraborty, Kshitij Gajjar, and Agastya Vibhuti Jha. Approximating the center ranking under Ulam. In 41st IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS 2021), volume 213 of Leibniz International Proceedings in Informatics (LIPIcs), pages 12:1–12:21. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2021.
[13] Moses Charikar and Robert Krauthgamer. Embedding the Ulam metric into . Theory of Computing, 2(11):207–224, 2006.
[14] Graham Cormode, Shan Muthukrishnan, and Süleyman Cenk Sahinalp. Permutation editing and matching via embeddings. In International Colloquium on Automata, Languages, and Programming, pages 481–492. Springer, 2001.
[15] Cynthia Dwork, Ravi Kumar, Moni Naor, and D. Sivakumar. Rank aggregation methods for the web. In Proceedings of the Tenth International World Wide Web Conference, WWW 10, pages 613–622, 2001.
[16] Ronald Fagin, Ravi Kumar, and D. Sivakumar. Efficient similarity search and classification via rank aggregation. In Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data, San Diego, California, USA, June 9-12, 2003, pages 301–312, 2003.
[17] 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.
[18] Mursalin Habib. Ulam median is NP-hard for four permutations. arXiv preprint arXiv:2608.05544, 2026.
[19] Donna Harman. Ranking algorithms. In William B. Frakes and Ricardo A. Baeza-Yates, editors, Information Retrieval: Data Structures & Algorithms, pages 363–392. Prentice-Hall, 1992.
[20] Johan Hästad. Some optimal inapproximability results. Journal of the ACM, 48(4):798–859, 2001.
[21] Ragesh Jaiswal, Amit Kumar, and Jatin Yadav. Robust-sorting and applications to Ulam-Median. In 52nd International Colloquium on Automata, Languages, and Programming (ICALP 2025), pages 100–1. Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2025.
[22] Claire Kenyon-Mathieu and Warren Schudy. How to rank with few errors. In Proceedings of the thirty-ninth annual ACM symposium on Theory of computing, pages 95–103, 2007.
[23] Joseph B Kruskal. An overview of sequence comparison: Time warps, string edits, and macromolecules. SIAM review, 25(2):201–237, 1983.
[24] Péter Madarasi. The complexity of kemeny aggregation with three rankings. arXiv preprint arXiv:2607.28588, 2026.
[25] Timothy Naumovitz, Michael E. Saks, and C. Seshadhri. Accurate and nearly optimal sublinear approximations to Ulam distance. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 2012–2031, 2017.
[26] François Nicolas and Eric Rivals. Complexities of the centre and median string problems. In 14th Annual Symposium on Combinatorial Pattern Matching, CPM 2003, pages 315–327, 2003.
[27] Dominik Peters. Kemeny rank aggregation is NP-hard for three voters. arXiv preprint arXiv:2607.25540, 2026.
[28] David Sankoff. Minimal mutation trees of sequences. SIAM Journal on Applied Mathematics, 28(1):35–42, 1975.
A Balanced Max-3-SAT Hardness
We establish two balanced hardness results used in Section 3. The first justifies the balance assumption for the exact decision reduction. The second establishes the balanced gap needed for hardness of approximation.
Lemma A.1. There is a polynomial-time transformation that maps any 3-CNF formula , in which every clause contains exactly three literal occurrences, to a 3-CNF formula such that:
-
every clause of contains exactly three literal occurrences;
-
every variable of has equally many positive and negative occurrences;
-
is satisfiable if and only if is satisfiable; and
-
the number of clauses in is linear in the number of clauses in .
Consequently, 3-SAT remains NP-hard under the first two restrictions.
Proof. For each variable , let and denote the numbers of positive and negative occurrences of in , respectively. If , add clauses of the form
using a fresh variable in each added clause. If , add clauses of the form
again using a fresh variable in each clause.
Clearly, the new formula is balanced. Furthermore, each added clause is a tautology. Thus, is satisfiable if and only if is satisfiable.
If has clauses, then
Thus, at most clauses are added, and the resulting formula has at most clauses.
Lemma A.2. For every fixed , it is NP-hard to distinguish 3-CNF formulas with clauses for which from those for which , even when every clause contains exactly three distinct variables and every variable has equally many positive and negative occurrences.
Proof. Let be the number of linear equations in the MAX-E3-LIN-2 instance. We apply Theorem 2.2 with . For each equation
there are exactly four assignments to that violate the equation. For each such assignment, introduce the clause on that is false precisely on that assignment. Thus, an assignment satisfying the equation satisfies all four clauses, whereas an assignment violating the equation satisfies exactly three. Moreover, among the four violating assignments, each variable takes each value exactly twice. Hence each variable occurs twice positively and twice negatively among the four clauses.
Let be the resulting formula, with clauses. Every clause contains three distinct variables, and every variable has equally many positive and negative occurrences. If an assignment satisfies equations in the original system, then
In the completeness case, some assignment therefore satisfies at least
clauses. In the soundness case, every assignment satisfies at most
clauses. The construction is polynomial-time and proves the lemma.
B Approximation for a Fixed Number of Inputs
Let be an instance of Ulam median, where each is a permutation of an alphabet of size . We assume that is fixed. In this section, we give an
approximation algorithm. In particular, for , this gives a 5/4-approximation.
For brevity, let .
Theorem B.1. For every fixed , there is a deterministic algorithm running in time, returning a permutation such that
For , returning any permutation from the input gives an optimal solution. Chakraborty, Das, and Krauthgamer [10] gave an exact algorithm for and a 3/2-approximation for every fixed , based on a dynamic program for an edit-median relaxation. The algorithm in Theorem B.1 also uses the same relaxation and dynamic program but refines the rounding step and its analysis. It computes an optimal length- string over , which may contain repeated symbols and omit others. It then rounds this relaxed solution to a permutation by removing duplicate occurrences and inserting the missing symbols, while controlling the resulting increase in cost.
We describe and analyze the algorithm using insertion-deletion edit distance. For strings and , define
This definition applies to arbitrary strings, not necessarily permutations. When and are permutations of , both have length , and hence
Algorithm. The algorithm in Theorem B.1 consists of the following steps.
Step 1. Compute a length- string using the dynamic programming algorithm in [10]. For each , fix an optimal alignment between and .
Step 2. For each repeated symbol in , keep an occurrence used by the largest number of the alignments ; delete its other occurrences. Let be the resulting string.
Step 3. Fix one reference input, say . Obtain a permutation by inserting all missing symbols into following the order of , restricted to the symbols in the retained alignment and the missing symbols.
Return .
Running time. Step 1 can be implemented in time (see [10, Section 5]). Step 2 and Step 3 run in and time respectively. Hence, the total running time is .
Approximation Ratio. Recall that in Step 1, we obtain a string . Let
Occurrences of repeated symbols are removed in Step 2 and missing symbols are inserted in Step 3. Let
Thus, is the number of symbols missing from . Since has length , is also the number of duplicate occurrences removed in Step 2.
Lemma B.2. and .
Proof. By definition of , , for any permutation . Choose to be the permutation attaining , and note that , it follows that .
To bound , observe that is the number of symbols in that do not appear in . Therefore, the number of unmatched positions between and each must be at least , namely, . Thus,
and hence, .
Let be the indicator of the parity of , namely, if is odd, and 0 otherwise. The following lemma shows that Step 2 reduces the cost by at least .
Lemma B.3. Let be the string obtained from Step 2, then .
Proof. For each , let be the number of matched pairs in the fixed optimal alignment , so that . Let be the number of these matched pairs whose occurrence in is deleted in Step 2, and set .
Consider any deleted occurrence, and let t be the number of fixed alignments in which it is matched. The retained occurrence of the same symbol is matched in at least t alignments. Since each input permutation contains the symbol exactly once, no alignment can match both occurrences. Hence , and summing over the M deleted occurrences gives
Restricting to the undeleted occurrences gives a common subsequence of and of length . These retained alignments need not be optimal, but they provide the bounds
Since and , it follows that
□
Lemma B.4. Let be the permutation obtained from Step 3, then .
Proof. Use the notation from the proof of Lemma B.3. The retained part of gives a common subsequence of and of length . Step 3 inserts all missing symbols in their order into the gaps determined by this subsequence. Thus, the retained matches together with the inserted symbols form a common subsequence of and , giving
For every other input, insertion preserves all retained matches, so
Both and each have length . Therefore, using , we obtain

Figure 4: The median-to-center reduction for . Cyclic shifts place every original input once in every row and column, preserving the optimum.
Proof of Theorem B.1. It suffices to analyze the approximation factor of the permutation . Applying Lemma B.4 and Lemma B.2, we have
C Reduction from the Ulam Median to the Ulam Center
Proof of Lemma 6.1. For each , let be a disjoint copy of . For a permutation , let denote its copy on . The center instance is defined over the alphabet as follows. For each , define
where the notation denotes the sum modulo . Thus, every contains one copy of every input permutation, and these copies are cyclically shifted across the blocks. The construction is illustrated in Figure 4.
We first show that a center candidate can be assumed to respect the common block order. Let be an arbitrary permutation of , and let be obtained by stably sorting the symbols of according to the block order , while preserving the relative order within each block. Every has this same block order. Hence every common subsequence of and already visits the blocks in this order, and stable sorting preserves such a subsequence. Therefore, for every ,
For each , let denote the restriction of to the -th alphabet copy , where the symbols are replaced by their counterparts in the original alphabet . Since and have the same block order, their LCS decomposes across the blocks, and therefore
Averaging over gives
The second equality holds because, for every fixed , the cyclic index ranges over exactly once as ranges over . Since
every center candidate has radius at least . Hence
For the reverse inequality, let be an optimal median for , and consider
For every , the block decomposition gives
Thus, has radius , and therefore
Together with the previous lower bound, this proves equality of the optimum values.
Finally, suppose that a center solution has radius at most . Construct and as above. Since stable sorting does not increase any distance, for every . Therefore,
Hence at least one satisfies . Computing all and returning one of minimum cost proves the extraction claim.