Shortest common supersequence: Difference between revisions
imported>Giftlite simplify |
imported>AmirOnWiki APX-completeness |
||
| Line 19: | Line 19: | ||
|doi=10.1016/0304-3975(81)90075-x | |doi=10.1016/0304-3975(81)90075-x | ||
|doi-access= | |doi-access= | ||
}}</ref> | }}</ref> Moreover, it is [[APX]]-complete<ref>Blum, Avrim, Tao Jiang, Ming Li, John Tromp, and Mihalis Yannakakis. "Linear approximation of shortest superstrings." Journal of the ACM (JACM) 41, no. 4 (1994): 630-647.</ref>. | ||
Several constant factor approximations have been proposed throughout the years, and the current best known algorithm has an approximation factor of 2.475.<ref>{{cite book | |||
|author=Matthias Englert and Nicolaos Matsakis and Pavel Vesel | |author=Matthias Englert and Nicolaos Matsakis and Pavel Vesel | ||
|title=Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing | |title=Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing | ||
Latest revision as of 12:13, 28 June 2025
In computer science, the shortest common supersequence of two sequences X and Y is the shortest sequence which has X and Y as subsequences. This is a problem closely related to the longest common subsequence problem. Given two sequences X = < x1,...,xm > and Y = < y1,...,yn >, a sequence U = < u1,...,uk > is a common supersequence of X and Y if items can be removed from U to produce X and Y.
A shortest common supersequence (SCS) is a common supersequence of minimal length. In the SCS problem, two sequences X and Y are given, and the task is to find a shortest possible common supersequence of these sequences. In general, an SCS is not unique.
For two input sequences, an SCS can be formed from a longest common subsequence (LCS) easily. For example, the longest common subsequence of X and Y is Z. By inserting the non-LCS symbols into Z while preserving their original order, we obtain a shortest common supersequence U. In particular, the equation holds for any two input sequences.
There is no similar relationship between shortest common supersequences and longest common subsequences of three or more input sequences. (In particular, LCS and SCS are not dual problems.) However, both problems can be solved in time using dynamic programming, where is the number of sequences, and is their maximum length. For the general case of an arbitrary number of input sequences, the problem is NP-hard.[1]
Shortest common superstring
The closely related problem of finding a minimum-length string which is a superstring of a finite set of strings S = { s1,s2,...,sn } is also NP-hard.[2] Moreover, it is APX-complete[3]. Several constant factor approximations have been proposed throughout the years, and the current best known algorithm has an approximation factor of 2.475.[4] However, perhaps the simplest solution is to reformulate the problem as an instance of weighted set cover in such a way that the weight of the optimal solution to the set cover instance is less than twice the length of the shortest superstring S. One can then use the O(log(n))-approximation for weighted set-cover to obtain an O(log(n))-approximation for the shortest superstring (note that this is not a constant factor approximation).
For any string x in this alphabet, define P(x) to be the set of all strings which are substrings of x. The instance I of set cover is formulated as follows:
- Let M be empty.
- For each pair of strings si and sj, if the last k symbols of si are the same as the first k symbols of sj, then add a string to M that consists of the concatenation with maximal overlap of si with sj.
- Define the universe of the set cover instance to be S
- Define the set of subsets of the universe to be { P(x) | x ∈ S ∪ M }
- Define the cost of each subset P(x) to be |x|, the length of x.
The instance I can then be solved using an algorithm for weighted set cover, and the algorithm can output an arbitrary concatenation of the strings x for which the weighted set cover algorithm outputs P(x).Template:Sfn
Example
Consider the set S = { abc, cde, fab }, which becomes the universe of the weighted set cover instance. In this case, M = { abcde, fabc }. Then the set of subsets of the universe is
which have costs 3, 3, 3, 5, and 4, respectively.
References
<templatestyles src="Reflist/styles.css" />
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Blum, Avrim, Tao Jiang, Ming Li, John Tromp, and Mihalis Yannakakis. "Linear approximation of shortest superstrings." Journal of the ACM (JACM) 41, no. 4 (1994): 630-647.
- ↑ Script error: No such module "citation/CS1".
Script error: No such module "Check for unknown parameters".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".