To understand the word "center", it is necessary to define a distance between two strings. Usually, this problem is studied with the Hamming distance in mind.
More formally, given n length-m strings s1, s2, ..., sn, the closest string problem seeks for a new length-m string s such that d(s,si) ≤ k for all i, where d denotes the Hamming distance, and where k is as small as possible. A decision problem version of the closest string problem, which is NP-complete, instead takes k as another input and asks whether there is a string within Hamming distance k of all the input strings.
The closest string problem can be seen as an instance of the 1-center problem in which the distances between elements are measured using Hamming distance.
Simplifications and data reductions
Instances of closest string may contain information that is not essential to the problem. In some sense, the usual input of closest string contains information, that does not contribute to the hardness of the problem. For example, if some strings contain the character a, but none contains the character z, replacing all as with zs would yield an essentially equivalent instance, that is: from a solution of the modified instance, the original solution can be restored, and vice versa.
Normalizing the input
When all input strings that share the same length are written on top of each other, they form a matrix. Certain row types have essentially the same implications to the solution. For example, replacing a column with entries (a, a, b) with another column (x, x, y) might lead to a different solution string, but cannot affect solvability, because both columns express the same structure, viz. the first two entries being equal, but different from the third one.
An input instance can be normalized by replacing, in each column, the character that occurs the most often with a, the character that occurs the second most often with b, and so forth. Given a solution to the normalized instance, the original instance can be found by remapping the characters of the solution to its original version in every column.
The order of the columns does not contribute to the hardness of the problem. That means, if we permute all input strings according to a certain permutation π and obtain a solution string s to that modified instance, then π−1(s) will be a solution to the original instance.
Given an instance with three input strings uvwx, xuwv, and xvwu. This could be written as a matrix like this:
The first column has the values (u, x, x). As x is the character that appears the most often, we replace it by a, and we replace u, the second most often character, by b, obtaining the new first column (b, a, a). The second column has the values (v, u, v). As for the first column, v is replaced by a and u is replaced by b, obtaining the new second column (a, b, a). Doing the same with all columns gives the normalized instance
Data reduction obtained from normalization
Normalizing the input reduces the alphabet size to at most the number of input strings. This can be useful for algorithms whose running times depend on the alphabet size.
Closest String can be solved in , where k is the number of input strings, L is the length of all strings and d is the desired maximum distance from the solution string to any input string.
Relations to other problems
Closest string is a special case of the more general closest substring problem, which is strictly more difficult. While closest string turns out to be fixed-parameter tractable in a number of ways, closest substring is W-hard with regard to these parameters.
- Lanctot, J. Kevin; Li, Ming; Ma, Bin; Wang, Shaojiu; Zhang, Louxin (2003), "Distinguishing string selection problems", Information and Computation, 185 (1): 41–55, doi:10.1016/S0890-5401(03)00057-9, MR 1994748
- Bin Ma and Xiaming Sun (2008), More Efficient Algorithms for Closest String and Substring Problems (PDF), LNCS, 4955, Springer, pp. 396–409, doi:10.1007/978-3-540-78839-3_33
- M. Li, B. Ma, and L. Wang. (2002), "On the Closest String and Substring Problems." (PDF), Journal of the ACM, 49 (2): 157–171, doi:10.1145/506147.506150
- Jens Gramm, Rolf Niedermeier, and Peter Rossmanith (2003), "Fixed-Parameter Algorithms for Closest String and Related Problems", Algorithmica, 37: 25–42, doi:10.1007/s00453-003-1028-3