Exploring the Gap Between LCS and LCStr
Abstract
The Longest Common Subsequence (LCS) problem and the Longest Common Substring (LCStr) problem are classical string problems with broad theoretical and practical significance. The former has a quadratic conditional lower bound [FOCS, 2015], while the latter admits a linear-time solution.
In this paper, we study a natural variation of these problems, the Longest Common Subsequence-Substring (LCSS) problem. The LCSS problem seeks the longest string that is simultaneously a subsequence of one input string and a substring of the other. This variant bridges LCS and LCStr, raising intriguing algorithmic questions: Does the complexity of computing LCSS interpolate between the linear time of LCStr and the quadratic time of LCS? What about approximability? We also examine a natural extension of LCSS to multiple strings, parameterizing the balance between subsequence and substring requirements.
Our results reveal several insights. First, under the SETH conjecture, the inherent complexity of LCSS is quadratic, similar to LCS. In contrast, we provide a linear-time approximation for LCSS. Finally, for the multi-string variant, unlike both problems, we design a quadratic-time algorithm, uncovering deeper structural properties of the problem.
By studying the complexity of the LCSS problem, we aim to gain some understanding of what influences whether a variant of the LCS problem behaves more like the standard LCS or like LCStr. Our findings suggest that hybrid constraints can create computational “sweet spots,” where problems become more tractable than their pure counterparts. This opens a broader research direction in constraint-mediated algorithm design.
Beyond LCSS itself, our work highlights unexpected connections between subsequence and substring constraints, advancing the theoretical understanding of string problems and laying the foundation for new algorithmic techniques and complexity-theoretic insights in the rich space between classical string comparison paradigms.
Keywords and phrases:
Longest Common Subsequence, Longest Common Substring, Conditional Lower BoundFunding:
Shay Golan: partially supported by Israel Science Foundation grant 810/21.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Problems, reductions and completenessEditors:
Philip Bille and Nicola PrezzaSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction and Previous Work
LCS.
The Longest Common Subsequence (LCS) problem is one of the classical problems in computer science. Its first well-known quadratic-time dynamic programming solution was presented in 1974 by Wagner and Fischer [77]. In this problem, we are given two strings over the same alphabet and seek the length of the longest subsequence common to both strings, where a subsequence is obtained from a sequence by deleting zero or more elements. LCS has numerous applications, including in genetics and molecular biology [26, 30, 33, 80], optical character recognition (OCR) [42], and other domains. A wide range of algorithms has been proposed for solving LCS; see, for example, the surveys [21, 72].
Given its importance, many variants of LCS have been studied over the years. These include LCS for multiple strings (e.g., [1, 62, 79]), LCS under correlated sequence models [44], tree LCS (e.g., [11, 69]), weighted LCS (e.g., [10, 18]), the Longest Common Increasing Subsequence (e.g., [32, 27, 37]), constrained LCS (e.g., [13, 40, 46, 47, 57]), the Longest Common Parameterized Subsequence [45, 55, 63], and the Longest Common Palindromic Subsequence [16, 36, 61], among many other generalizations (e.g., [20, 22, 26, 54, 56]).
LCStr.
In the Longest Common Substring (LCStr) problem, the goal is to find a common substring of the input strings, rather than a subsequence. Equivalently, LCStr can be viewed as a variant of the LCS problem in which the common subsequence is required to be a substring of both input strings. The LCStr problem is a fundamental problem in string processing, with numerous applications [4, 31, 35, 43]. It admits a straightforward linear-time solution using a (generalized) suffix tree [48, 81]. The problem has also been studied in various models and settings, including small-space algorithms [75, 65, 19], dynamic strings [8, 7, 9, 28], packed string representations [29], LCStr with up to mismatches [41, 76, 64, 29], and LCStr with up to edits [6].
To explore the gap between the LCS and LCStr problems, we briefly review their time complexity, approximation algorithms, and multi-string variants. This serves as a baseline for analyzing the LCSS problem.
Time complexity of LCS and its variations.
Abboud et al. [1] and Bringmann and Künnemann [25] showed that any subquadratic-time algorithm for LCS would refute the Strong Exponential Time Hypothesis (SETH). Abboud et al. [2] further strengthened this result by showing that even a strongly subquadratic-time algorithm for LCS would refute a natural, weaker variant of SETH defined over branching programs.
Moreover, Bringmann and Künnemann [23] conducted a systematic study of the multivariate complexity of LCS, taking into account a wide range of parameters that influence the running time (such as input size, the length of the shorter string, and the length of the LCS). For any class of instances obtained by bounding each parameter by a polynomial in the input size, they established corresponding SETH-based lower bounds.
Generalizations of LCS and LCStr to multiple strings.
To compute the Longest Common Substring of strings, Hui [52] showed that a (generalized) suffix tree can be exploited to obtain a linear-time algorithm.
The problem of finding the LCS of strings is commonly referred to as -LCS. Maier [68] proved that -LCS is NP-complete when is unbounded, even over an alphabet of size . Over the years, several algorithms have been proposed for this problem. For example, Irving and Fraser [62] presented an algorithm with running time , where is the common length of the input strings and is the length of an LCS. For the special case of three strings, Wang and Zhu [78] proposed two algorithms with running times and , where denotes the minimum number of deletions required to obtain a common subsequence, and is the number of matching triples such that . In the worst case, however, these approaches require time.
Approximation versions of LCS and LCStr.
For LCStr, the existence of a linear-time exact algorithm immediately implies a linear-time approximation algorithm. Moreover, a sublinear-time approximation with a constant factor is unlikely, as it would yield a sublinear-time algorithm for testing equality between two strings.
For LCS, simple near-linear-time algorithms achieve either a -approximation or a -approximation, where is the input size and is the alphabet. In recent years, several works have studied the approximation of LCS. Abboud and Rubinstein [3] explored connections between approximate LCS and circuit complexity. Rubinstein and Song [74] showed that a -approximation can be obtained in subquadratic time for two equal-length strings over a binary alphabet. This result was later improved by Akmal and Vassilevska Williams [5], who achieved a -approximation in subquadratic time for any constant-size alphabet. For large alphabets, HajiAghayi et al. [49] improved the -approximation to while maintaining linear running time. Subsequently, Bringmann et al. [24] further improved the approximation ratio to and introduced a trade-off between the approximation ratio and the running time. In an unpublished manuscript, Nosatzki [73] described a linear-time algorithm achieving an approximation ratio of . Notably, all algorithms whose approximation guarantees depend on (rather than ) are randomized.
LCS variations bridging the gap between the LCS and LCStr problems.
The contrasting complexity landscape of LCS and LCStr indicates that restricting the search to substrings significantly simplifies the problem. Several variants of LCS aim to bridge this gap by requiring the common subsequence to include substrings; see, e.g., [17, 20].
Recently, Banerjee et al. [17] introduced the Longest Common Factor with Gaps (-LCFg) problem, in which the common subsequence is composed of at most matching substrings, and the objective is to maximize their total length. They provide an algorithm with running time .
Benson et al. [20] defined the problem, where the common subsequence must consist of substrings of length exactly in both input strings. Several algorithms have been proposed for [20, 34, 51, 84], all of which have quadratic worst-case running time.
Both problems incorporate substrings into the subsequence structure, but in different ways: -LCFg allows substrings of unbounded length but limits their number, whereas allows an unbounded number of substrings, each of fixed length. This distinction becomes especially pronounced when : in this case, -LCFg reduces to LCStr, while coincides with LCS.
Exploring the gap between LCS and LCStr.
Recall that LCStr can be viewed as a variant of LCS in which the common subsequence is required to be a substring of both input strings. Given the substantial gap in complexity between LCS and LCStr (and their variants), a natural question arises: which additional constraints on LCS lead to problems whose complexity remains closer to that of LCS rather than LCStr?
Requiring substrings of fixed length (as in ) appears to preserve the complexity characteristics of LCS. In contrast, allowing substrings of arbitrary length (as in -LCFg) can break the quadratic-time barrier, bringing the problem closer to LCStr in terms of complexity.
Notably, both and -LCFg require the subsequence to consist of substrings from both input strings. This raises a natural question: what happens if this requirement is imposed on only one of the strings? To address this question, we consider an intermediate variant between LCS and LCStr, in which the common subsequence is required to be a substring of one of the input strings. This problem, called the Longest Common Subsequence-Substring (LCSS), is defined as follows.
Problem 1 (LCSS).
Given two strings and over an alphabet , of lengths and , respectively, compute the maximum length of a subsequence of that is also a substring of .
For example, let and . Then , and one longest common subsequence-substring is abaabc.
In addition to its theoretical interest, the LCSS problem is motivated by applications in cybersecurity. In such settings, malware signatures are often fragmented and transmitted across multiple packets, making detection challenging [66]. Given a set of signatures separated by a designated symbol, one may wish to identify the longest signature that appears as a subsequence in observed data, effectively detecting a single, possibly fragmented, occurrence. A related problem, Dictionary Matching with a Few Gaps [12], focuses on detecting all occurrences of patterns from a dictionary. In contrast, the LCSS formulation targets the detection of a single (longest) fragmented pattern.
Li, Deka, and Deka [67] introduced the LCSS problem and proposed a naive quadratic-time algorithm. Observe that the longest prefix of a string that appears as a subsequence of can be computed in time using a two-pointer technique: the pointer on advances at every step, while the pointer on advances only upon a match. Applying this procedure to every suffix of yields an -time algorithm.
Our Contribution.
-
We first show (in Section 3) that the LCSS problem has inherent quadratic-time complexity, up to subpolynomial factors, under the Strong Exponential Time Hypothesis (SETH), via a reduction from the Orthogonal Vectors problem. This lower bound indicates that the additional constraint imposed by LCSS, compared to LCS, does not lead to a computationally easier problem, and in particular does not bring its complexity closer to that of LCStr.
-
We then show (in Section 4) that for instances where is small, the running time can be improved to , where , , , and is the alphabet.
-
Furthermore, we study (in Section 4.1) the LCSS problem for multiple strings (formally defined in Problem 15) in order to better understand its computational relationship to LCS and LCStr. Our results indicate that, in this setting, the problem behaves differently from both. In particular, for a constant number of strings and , each of length , we present an algorithm with running time , where .
-
Finally, we present (in Section 5) a -approximation algorithm for LCSS that runs in near-linear time, matching the time complexity of LCStr up to logarithmic factors. To the best of our knowledge, no comparable approximation results are known for the LCS problem.
2 Preliminaries
Below, we present some basic notations and a data structure definition used in this paper. For every two integers we denote by the set of integers between and . We also denote . A string of length over an alphabet (we assume that is polynomial in the input size) is a sequence of symbols . The length of the string is denoted by . For every , the substring . If we say that is a prefix, and if , it is a suffix. Given a string of length , the th cyclic shift of is the string for some , where denotes concatenation. Let and be two strings over the same alphabet. A common subsequence-substring of and (CSS) is a string where is a subsequence of and a substring of .
A useful tool for our results is the following data structure.
Lemma 2.
For a string of length over an alphabet , there is a linear-space data structure that preprocess in time, and supports answering the following query in time: Given a character , and an index , determine the leftmost position of the character in (or report if such an occurrence does not exist).
Proof.
We describe hereafter a data structure that satisfies the requirements of the lemma. In the preprocess we employ the following technique. is divided into chunks of length each (except for the last chunk which may be shorter). Chunk represents substring for . For each chunk , we maintain two self-balancing binary search trees (BST), each of size :
-
1.
. For every , stores a sorted array which stores the positions of all occurrences of within the corresponding substring of . The arrays are constructed by scanning the substring corresponding to and inserting each symbol into its respective array. We emphasize that for every the length of the array , is exactly the number of occurrences of in the substring corresponding to .
-
2.
. For every , stores the position of the first occurrence of that is after the end of chunk , i.e., in . If does not occur in the rest of , then . To fill the values for each we scan the string in reverse, from the end to the beginning, while maintaining an additional self-balancing binary search tree, which stores for each that we already scanned, its most recent occurrence. When we reach the end of a chunk’s scope, i.e., position , we copy the contents of into .
An example of the data structure constructed during preprocessing is shown in Figure 1.
Given a query of , and an index , we need to find the first occurrence of in . We assume that , as otherwise the algorithm trivially returns . Consider the chunk where , i.e., . We use to access on which we perform a binary search on to find the smallest element that is at least . In case there is no such element, return the value saved in , or if such a value does not exist.
Time complexity.
The construction of each BST over symbols requires time. The time required to construct each is linear in its length, thus, all arrays within a chunk , collectively store symbols indices, are constructed in time. Given that there are chunks, the total time required for constructing the sorted arrays is . The time complexity for the scan that the algorithm executes for filling the OUT arrays is also .
Finally, to answer a query, the algorithm uses (at most) two balanced binary search tree of size at most and executes a binary search on an array of length . Thus, the time complexity of answering a query is
Approximation Algorithm.
Let be a maximization problem, and let denote the optimal value of an instance . An algorithm is said to be a -approximation for (for ) if for every instance , it returns a solution of value such that . That is, the value of the solution returned by is guaranteed to be at least a -fraction of the optimal value.
Suffix Tree Construction.
The following lemma by Farach-Colton, Ferragina and Muthukrishnan [39] introduce a linear-time construction algorithm for a suffix tree of a string with polynomial integer alphabet.
Lemma 3 (Farach-Colton et al. [39]).
Let be a string of length over an integer alphabet of size . Then one can construct the suffix tree of in time on the word-RAM model.
Given a set of strings over an alphabet of size polynomial in the total input length, all suffix trees can be constructed in linear time, as stated in the following lemma. This will be useful in our algorithms.
Lemma 4.
Let be a set of non-empty strings over an integer alphabet . For every , let , and let . If for some constant , then on the word-RAM model there exists an algorithm that computes the suffix tree of every string in in total time.
Proof.
The proof consists of two steps.
First, we rename the letters of each string so that each string gets its own alphabet of size at most its length. For every occurrence of a letter in the input, create a record , where is the index of the string, , and is the position of this occurrence inside . There are exactly such records.
We sort these records lexicographically by the pair . Since and , both coordinates fit in bits. Hence the sorting can be done in time by radix sort.
We now scan the sorted list. For each fixed string , whenever we encounter a new letter value , we assign it the next rank in among the distinct letters of . Let be the resulting renamed string. This scan clearly takes time. If is the number of distinct letters in , then is over the alphabet , where . Moreover, the renaming preserves equality and inequality of letters inside each fixed string, so the suffix tree of is obtained from the suffix tree of by replacing the renamed letters by the original ones. Thus it is enough to construct the suffix trees of the strings .
Second, for every , append to a terminal symbol that is smaller than all alphabet symbols and appears only once. Since we build each suffix tree separately, we may simply use the same fresh terminal symbol for every . Now has length and its alphabet size is at most . Therefore, by Lemma 3, the suffix tree of can be built in time.
Summing over all , the total time for this step is . Together with the time of the renaming step, the overall running time is . Hence all suffix trees can be computed in total time.
3 LCSS Lower Bound
In this section, we show that a quadratic complexity is inherently necessary for solving the LCSS problem, similar to the LCS problem. Formally, we prove the following theorem.
Theorem 5.
Let . There is no algorithm for the LCSS problem with running time, unless SETH is false.
We develop a reduction from the Orthogonal Vectors (OV) problem. Williams [82] shows that any algorithm for the OV problem with strongly sub-quadratic running time would break the Strong Exponential Time Hypothesis (SETH), introduced in [59, 60]. Formally, we define the OV problem, and state its conditional lower bound as follows.
Problem 6 (OV).
Given two sets with , determine whether there exist , such that , where .
Lemma 7 ([82]).
If for some , OV on vectors in for can be solved in time, then SETH is false.
Let denote the vector and denote the vector. We note that instances of the OV problem where are easy to solve in linear time. Therefore, when reducing the OV problem to other problems, we assume without loss of generality that .
For two strings and we say that is a cyclic subsequence of if and only if there is an such that the th cyclic shift of is a subsequence of . We define an intermediate problem, the Cyclic Subsequence problem, as follows.
Problem 8 (Cyclic Subsequence).
Given two input strings and of lengths and respectively, return true if and only if is a cyclic subsequence of .
We will first show (in Section 3.1) a reduction from the OV problem to the Cyclic Subsequence problem, establishing the hardness of the Cyclic Subsequence problem. Then (in Section 3.2), we describe a second reduction from the Cyclic Subsequence problem to the LCSS problem.
3.1 Reducing the OV Problem to Cyclic Subsequence Using Constant Size Alphabet
In this section, we prove a conditional lower bound for Problem 8, by presenting a reduction from the OV problem, using a constant size alphabet.
The Reduction.
Given two sets and we define strings and , over an alphabet as follows. For , let for such that is a -entry index in , otherwise is an empty string. Similarly, for , let for such that is a -entry index in , otherwise is an empty string. We define the vector gadgets (where denotes sequential concatenation):
The following lemma establishes the relation between the orthogonality of and and the property of one vector gadget being a subsequence of the other.
Lemma 9.
is a subsequence of if and only if
Proof.
According to the construction, consists of occurrences of symbols, with a preceding the th whenever . Similarly, consists of occurrences of symbols, with a preceding the th whenever .
If the vectors and are orthogonal, then for every index such that , it holds that . Thus, in addition to the matching symbols, if a symbol appears before the th in then a corresponding symbol appears before the th in . Finally, note that the symbols always match, as they mark the ends of both vector gadgets. Therefore, is a subsequence of .
If is a subsequence of , this implies that for every symbol in , if it appears before the th in , then a corresponding must appear before the th in , as otherwise not all symbols in could be matched with those in . Therefore, for every index such that , it must be that . This implies that the vectors and are orthogonal.
Given and we define sequences gadgets and , as follows.
A visualization of the defined sequence gadgets is shown in Figure 2.
We refer to as the -th segment of .
Vector-shifts.
Recall that ends with a sign. We define a vector-shift on as the operation of applying (left) cyclic shifts until ends with a sign again. Notice that encodes the sequence , and after a single vector-shift we obtain an encoding of the sequence . In general, if a string is the encoding of a sequence of vectors, then by applying a vector-shift on the string we obtain the encoding of cyclic shifted sequence of vectors.
The following two lemmas prove that is a cyclic subsequence of if and only if there are vectors and such that .
Lemma 10.
If there are vectors and such that then is a cyclic subsequence of .
Proof.
Since we are searching for a cyclic subsequence, can be vector-shifted until the obtained string is the encoding of cyclic shift of such that appears in the th position of the sequence. Let be this cyclic shift of
Since , Lemma 9 implies that is a subsequence of . Now, consider the pair of prefixes and the pair of suffixes of and until and after and . In , to the left of , there are occurrences of . Similarly, in there are vector gadgets of type to the left of , each of which is a subsequence of , by Lemma 9. Similarly, to the right of in , there are occurrences of , these include occurrences from the last segments of , along with one additional occurrence from the th segment. Correspondingly, in there are vector gadgets of type to the right of , each of which is a subsequence of , by Lemma 9. To conclude, we deduce that , that is a cyclic shift of , is a subsequence of , hence, we prove the lemma.
Lemma 11.
If is a cyclic subsequence of then there are vectors and such that .
Proof.
Let be a cyclic shift of such that is a subsequence of . First, we show that, without loss of generality, we can assume that is a result of applying vector-shifts on . If this is not the case, it means that there is a vector gadget for some that was split by the cyclic shifts. Let be the first index in such that (this is the sign of ). Since is a subsequence of we can assume (without loss of generality) that the prefix of was matched as a subsequence to the end of , specifically, to the last occurrence of . As a result, we can perform a cyclic shift of symbols, meaning the prefix is appended to the end of the string and removed from the beginning, to obtain a new string that ends with the complete vector gadget , and therefore is a result of vector-shifts on . The complete can still be matched as a subsequence to the final occurrence of of . Hence, if is matched as a subsequence to , then matches as well.
We say that is a valid one to one mapping from if for every , where and for every . Given that is a subsequence of , there exists at least one valid mapping .
We say that an instance -touches an instance if a symbol from is mapped by to a symbol from (there exists such that , where is part of for some and is part of for some ).
Claim 12.
Let be a substring of such that for some . Then, -touches at most one vector gadget (of type ) in .
Proof.
Intuitively, the claim holds since ends with a , and there is at least one between every two vector gadgets in . Formally, assume to the contrary that -touches two vector gadgets of . In particular, let and be the leftmost and rightmost indices of symbols of that are mapped to some index in , respectively (for example see Figure 3).
By definition, is a subsequence of . Since -touches two vector gadgets of it must be that the rightmost index of the vector gadget that contains in has . In addition, since is the last index of a vector gadget, it holds that . Recall that contains exactly one sign, and this sign is at position of . Thus, it must be that . However, by the monotonicity of , it must be that , which is a contradiction.
Notice that it can be the case that several valid mappings exist. Consider a mapping which maximize the number of gadgets that -touches a vector gadget of . Due to the reduction construction, contains occurrences of and contains vector gadgets, each a subsequence of , by Lemma 9. By Claim 12 and the pigeonhole principle, there is at least one vector gadget in that is not -touched by any instance of . Let be this vector gadget in . Since is a valid mapping, must be touched by at least one vector gadget of . Assume to the contrary that is touched by more than one vector gadget of . Let and . Recall that is not touched by a vector gadget. Thus, by the reduction construction, it must be that contains a vector gadget. Thus, there exists a valid mapping such that this vector gadget is also -touch: by modifying such that is mapped to this vector gadget (such a mapping exist by Lemma 9). Contradicting the maximality of . Thus, it must be the case that is touched by a single vector gadget of . This vector gadget must be for some . Notice that cannot be since by definition of .
Hence, if is a subsequence of , at least one for some must be a subsequence of for some , implying are orthogonal, according to Lemma 9.
We are now ready to prove the hardness of Problem 8.
Lemma 13.
For every , there is no algorithm that solves Problem 8 in time, unless SETH is false.
Proof.
Assume that Problem 8 can be solved in time for some . Let and be two sets of size , which are an input for the OV problem (Problem 6). The reduction described above takes time to construct and , both of size . By Lemmas 10 and 11, is a cyclic-subsequence of if and only if there are vectors and such that . Therefore, there is an algorithm that solves Problem 6 in time, which, by Lemma 7, refutes SETH.
3.2 Reducing Cyclic Subsequence to LCSS
After establishing the hardness of the Cyclic Subsequence problem (Problem 8), we are finally ready to prove the hardness of the LCSS problem by presenting a reduction from Problem 8 to the LCSS problem.
The Reduction.
Given an input for the Cyclic Subsequence problem, we construct two new strings , and .
Lemma 14.
if and only if is a cyclic subsequence of .
Proof.
If is a cyclic subsequence of , then there is an such that the th cyclic shift of , i.e., , is a subsequence of . Therefore, is a subsequence of and so .
On the other hand, if then there is an index such that is a subsequence of . Therefore, the th cyclic shift of is a subsequence of and so is a cyclic subsequence of .
Proof of Theorem 5.
Assume that there is an algorithm that computes LCSS in time for some . Given an input pair and of lengths and , respectively, to the Cyclic Subsequence problem, we construct and of lengths and , respectively, as described above, in time. By Lemma 14, running on and returns at least if and only if If is a cyclic subsequence of . Therefore, there exists an algorithm that solves Cyclic Subsequence in time. By Lemma 13 this refutes SETH.
4 LCSS Problem for Multiple Strings
We now turn our attention to a generalized version of the LCSS problem, involving multiple input strings, the Longest Common Subsequence-Substring problem for Multiple Strings (()-LCSS) problem, hereafter defined (see Figure 4 for an example).
Problem 15 (()-LCSS).
Given two sets of input strings and over an alphabet , where the strings of are of lengths and the strings of are of lengths . The goal is to find the length of the longest string such that the following conditions hold:
-
1.
is a subsequence of each .
-
2.
is a substring of each .
This length is denoted as .
We begin with a solution to the standard LCSS problem, i.e., (1,1)-LCSS. The algorithm iterates over each suffix of , for , and searches for its longest prefix that occurs as a subsequence in . This is done by sequentially locating the symbols of the current suffix of in , with the only constraint being that the corresponding symbols must appear in in increasing order. The matching process terminates when the current symbol of is no longer found in the remaining portion of . Since each iteration considers a different suffix of independently of the others, a variable is maintained to store the maximum length of the obtained common subsequence-substring so far. The LCSS algorithm is outlined in Algorithm 1.
Theorem 16.
Algorithm 1 solves the LCSS Problem in time and using space where and are the lengths of strings and respectively and .
Proof.
We begin with the correctness of the algorithm. We first note that the value of at any time is a length of some CSS of and , and therefore the output of the algorithm is at most . On the other hand, let be a longest CSS. Consider the th iteration of line Line 3. It is straightforward to see that by choosing greedily the first valid occurrence of a character at any inner iteration of Line 5, the algorithm obtains the longest possible prefix of that is a subsequence of . Therefore, the algorithm finds in the th iteration of Line 3 a CSS of length at least . Thus, the output of the algorithm is exactly .
Regarding the complexities, the initialization of the data structure of Lemma 2 at Line 1 takes time. It is clear that any outer iteration of Line 3 executes at most iterations of the inner-loop of Line 5. Each iteration of Line 5 takes time, dominated by the invocation of the query on . Thus, the time complexity of the algorithm is . The space requirement derives from Lemma 2.
4.1 -LCSS Solution
In the general case of ()-LCSS, the input includes a set of strings, and a set of strings. The goal is to find the (length of the) longest string that is a subsequence of all the strings in and also a substring of all the strings in .
We follow the idea of Algorithm 1, that is - the algorithm uses one string from as an anchor, and consider every suffix of separately. For a suffix , the algorithm finds the largest value such that the prefix of of length (which is ) is both a substring of all strings in and a subsequence of all strings in . Notice that . Thus, from now on we focus on the computation on a specific suffix .
To make this computation, the algorithm first computes in linear time for every suffix the largest such that is a substring of all strings of (ignoring the requirement to be a subsequence of strings in ). This is possible due to lemma Lemma 17. For its proof we utilize suffix trees. A suffix tree, first introduced by Weiner [81], is a compressed trie that represents all the suffixes of a given string. Each edge is labeled with a substring of the input string, and every path from the root to a leaf corresponds to a distinct suffix of the string. Edges can be stored using the starting position and length of the corresponding substring in the input string, resulting in a total space usage that is linear in the length of the string.
Lemma 17.
Let be a set of strings of lengths and let be a string of length such that for every . There exists an algorithm that outputs for every the largest such that is a substring of all the strings of . The algorithm runs in time.
Proof.
We suggest the following algorithm yielding an array of length , MaxCS, where for every , stores the length of the longest prefix of that is a common substring of all strings in , and is initialized to .
For every let where are unique terminal symbols. Let be the set of all strings . We use Lemma 4 to compute all suffix trees of strings in , and for every we denote by the suffix tree of .
The algorithm processes each suffix tree as follows. Recall that every leaf in the suffix tree corresponds to a suffix of the input string. Each leaf that corresponds to an index from the string is marked by , and each leaf that corresponds to an index from the string is marked by . Each leaf marked by stores the starting index of the suffix it represents. Additionally, for each node , we use to denote the length of the string represented by the path from the root to .
We associate to each :
(1) a boolean flag indicating whether the string represented by the path from the root to
is a substring of a suffix of
, initialized to false.
(2) a pointer , pointing to the nearest ancestor of that represents the longest prefix of a suffix of .
To update the flags , we traverse in postorder. A leaf node marked with sets its flag to true. For each internal node , if any of its children satisfies then is also set to true. Next, we perform an additional preorder traversal of . During this traversal, each node is assigned a value as follows: if , then , otherwise, where is the parent of .
We iterate over all indices . For each index let be the leaf representing the suffix in . Notice that indicates the length of the longest prefix of that is also a prefix of some suffix of . We update . We apply this procedure for each . After completing all iterations, we set .
Correctness.
For each suffix of , obtaining its longest common prefix with some yields the longest prefix of which is a substring of . The length of this substring is given by , where is the node representing the suffix in .
By maintaining as the minimum of all such values across every , we ensure that at the end of the procedure, stores the length of the longest prefix of that is a substring of all strings in , as required.
Complexities.
Notice that each string is of length . Hence, the algorithm of Lemma 4 takes time. For each iteration over updating the necessary values including those in array for each , takes linear time in the size of , i.e., time. Therefore, the overall time complexity of the algorithm is .
Let be the output of Lemma 17 for index . When the algorithm considers the suffix , it needs to find the largest such that is a subsequence of all strings in . Notice that is exactly . Similar to Algorithm 1, the algorithm advances a pointer on , verifying at every iteration that is still a subsequence of all strings of (notice that now instead of verifying this property for a single string , we need to make the verification for all of the strings in together). However, the algorithm does not need to advance more than times, since .
So, it only remains to describe how the algorithm is advancing the counter while verifying that is a subsequence of all strings of , instead of a single string (see Algorithm 2). To do this, at the initialization, the algorithm constructs the data structure of Lemma 2 for each string separately, denoted as . When reading the suffix , the algorithm initializes for every a pointer that maintains at the beginning of every iteration of Line 9 the smallest index such that is a subsequence of . Before advancing to , the algorithm makes the verification for every one after the other. The algorithm stops advancing when either or there is an such that is not a subsequence of , which the algorithm identifies by the fact that the data structure reports .
Theorem 18.
Algorithm 2 solves the -LCSS Problem (where ) in time where , , and . The algorithm uses linear space.
Proof.
Notice that at every outer-iteration of Line 5, the algorithm computes a valid length which is a length of a CSS of and . Therefore, the output of the algorithm is at most . On the other hand, consider a string that is a longest CSS of and . By definition it must be a substring of all strings in , and in particular of the shortest string that the algorithm chooses at Line Line 2. Let be an index of an occurrence of in . Following our discussion, at the th outer-iteration of Line 5, the algorithm will find . Thus, the algorithm outputs at least . To conclude the correctness, the algorithm outputs exactly .
We now focus on the complexity of the algorithm. The computation of the algorithm of Lemma 17 at Line 2 takes time and space by Lemma 17. The initialization of each at Line 3 takes time, summing up to time. Finally, there are exactly iteration of the outer-loop of Line 5. In each such iteration, the algorithm first initializes all pointers in time at Line 7. Then, the iteration executes at most iterations of the while-loop of Line 9. Each iteration of the while-loop iterates over all strings in (at Line 10) and for each one of them invoke a call for some that takes . Thus, the total time of all outer-iterations is . Summing up all factors, we obtain the stated running time. The space usage of the algorithm is linear in (which is the input size) due to Lemmas 17 and 2.
5 LCSS Approximation
In this section we present a -approximation algorithm for the LCSS problem, for a given . Let . We first describe how to compute a value corresponding to the length of a common subsequence such that, if then is a -approximation of . We then repeat this procedure for exponentially increasing values of , namely , and return the maximum value of obtained.
The algorithm is inspired by Algorithm 1, but instead of examining a common subsequence starting from every suffix of , it only considers a subset of suffixes. Specifically, define the set of positions in : The algorithm iterates over suffixes of the form for each . For each such suffix, it computes the length of the longest prefix of that appears as a subsequence of .
Note that the algorithm does not process the entire suffix up to position ; instead, it restricts attention to a window of length .
In the following we show that this algorithm yields a approximation of .
Lemma 19.
Assume , the algorithm described above computes a approximation of . Moreover, the algorithm runs (regardless of the assumption) in time.
Proof.
We first analyze the approximation ratio. Let be a longest CSS. Let be the minimum in the set such that . By the density of we have that and therefore . Moreover, since is a subsequence of , we also have that is a subsequence of . By our assumption, when scanning the suffix the algorithm finds at least the length . Thus, the reported value must be at least . On the other hand since the algorithm always reports a length of a CSS, clearly the reported value is at most .
Finally, the algorithm executes outer-iterations each one of them applies at most inner iterations and each inner-iteration takes time. Thus, the time complexity is .
By applying the algorithm times with exponential values of , it is clear that maximum reported value is a -approximation of , and that the running time is . Thus we obtain the following theorem.
Theorem 20.
Let . There exists an time algorithm that returns a -approximation of .
6 Conclusion and Future Work
In this paper, we study the time complexity of the LCSS problem. For a pair of strings we establish a quadratic lower bound and we introduce a near-linear time approximation algorithm. These results imply that requiring one of the common subsequence occurrences to be a substring does not reduce the quadratic time complexity of LCS. It seems that reducing the quadratic time requires restricting both input strings to consist of matching substrings, as done in the k-LCFg problem [17] of compiling a subsequence from at most substrings in both input strings.
Our findings motivate the definition of additional LCS variants with substring constraints, to further explore the gap between the LCS and LCStr problems and to support the assumptions emerging from our findings.
References
- [1] Amir Abboud, Arturs Backurs, and Virginia Vassilevska Williams. Tight hardness results for LCS and other sequence similarity measures. In 2015 IEEE 56th Annual Symposium on Foundations of Computer Science, pages 59–78, 2015. doi:10.1109/FOCS.2015.14.
- [2] Amir Abboud, Thomas Dueholm Hansen, Virginia Vassilevska Williams, and Ryan Williams. Simulating branching programs with edit distance and friends: or: a polylog shaved is a lower bound made. In Proceedings of the Forty-Eighth Annual ACM Symposium on Theory of Computing, STOC ’16, pages 375–388, New York, NY, USA, 2016. Association for Computing Machinery. doi:10.1145/2897518.2897653.
- [3] Amir Abboud and Aviad Rubinstein. Fast and Deterministic Constant Factor Approximation Algorithms for LCS Imply New Circuit Lower Bounds. In Anna R. Karlin, editor, 9th Innovations in Theoretical Computer Science Conference (ITCS 2018), volume 94 of Leibniz International Proceedings in Informatics (LIPIcs), pages 35:1–35:14, Dagstuhl, Germany, 2018. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ITCS.2018.35.
- [4] Amir Abboud, Ryan Williams, and Huacheng Yu. More applications of the polynomial method to algorithm design. In Proceedings of the twenty-sixth annual ACM-SIAM symposium on Discrete algorithms, pages 218–230. SIAM, 2014.
- [5] Shyan Akmal and Virginia Vassilevska Williams. Improved approximation for longest common subsequence over small alphabets. In Nikhil Bansal, Emanuela Merelli, and James Worrell, editors, 48th International Colloquium on Automata, Languages, and Programming, ICALP 2021, July 12-16, 2021, Glasgow, Scotland (Virtual Conference), volume 198 of LIPIcs, pages 13:1–13:18. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ICALP.2021.13.
- [6] Mai Alzamel, Maxime Crochemore, Costas S. Iliopoulos, Tomasz Kociumaka, Jakub Radoszewski, Wojciech Rytter, Juliusz Straszynski, Tomasz Walen, and Wiktor Zuba. Quasi-linear-time algorithm for longest common circular factor. In Nadia Pisanti and Solon P. Pissis, editors, 30th Annual Symposium on Combinatorial Pattern Matching, CPM 2019, June 18-20, 2019, Pisa, Italy, volume 128 of LIPIcs, pages 25:1–25:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. doi:10.4230/LIPIcs.CPM.2019.25.
- [7] Amihood Amir and Itai Boneh. Locally maximal common factors as a tool for efficient dynamic string algorithms. In Gonzalo Navarro, David Sankoff, and Binhai Zhu, editors, Annual Symposium on Combinatorial Pattern Matching, CPM 2018, July 2-4, 2018 - Qingdao, China, volume 105 of LIPIcs, pages 11:1–11:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2018. doi:10.4230/LIPIcs.CPM.2018.11.
- [8] Amihood Amir, Panagiotis Charalampopoulos, Costas S Iliopoulos, Solon P Pissis, and Jakub Radoszewski. Longest common factor after one edit operation. In International Symposium on String Processing and Information Retrieval, pages 14–26. Springer, 2017. doi:10.1007/978-3-319-67428-5_2.
- [9] Amihood Amir, Panagiotis Charalampopoulos, Solon P. Pissis, and Jakub Radoszewski. Longest common substring made fully dynamic. In Michael A. Bender, Ola Svensson, and Grzegorz Herman, editors, 27th Annual European Symposium on Algorithms, ESA 2019, September 9-11, 2019, Munich/Garching, Germany, volume 144 of LIPIcs, pages 6:1–6:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. doi:10.4230/LIPIcs.ESA.2019.6.
- [10] Amihood Amir, Zvi Gotthilf, and B. Riva Shalom. Weighted LCS. J. Discrete Algorithms, 8(3):273–281, 2010. doi:10.1016/J.JDA.2010.02.001.
- [11] Amihood Amir, Tzvika Hartman, Oren Kapah, B. Riva Shalom, and Dekel Tsur. Generalized LCS. Theor. Comput. Sci., 409(3):438–449, 2008. doi:10.1016/J.TCS.2008.08.037.
- [12] Amihood Amir, Avivit Levy, Ely Porat, and B Riva Shalom. Dictionary matching with a few gaps. Theoretical Computer Science, 589:34–46, 2015. doi:10.1016/J.TCS.2015.04.011.
- [13] Hsing-Yen Ann, Chang-Biau Yang, and Chiou-Ting Tseng. Efficient polynomial-time algorithms for the constrained LCS problem with strings exclusion. Journal of Combinatorial Optimization, 28(4):800–813, 2014. doi:10.1007/S10878-012-9588-2.
- [14] Alberto Apostolico. Improving the worst-case performance of the Hunt-Szymanski strategy for the longest common subsequence of two strings. Information Processing Letters, 23(2):63–69, 1986. doi:10.1016/0020-0190(86)90044-X.
- [15] Alberto Apostolico and Concettina Guerra. The longest common subsequence problem revisited. Algorithmica, 2:315–336, 1987. doi:10.1007/BF01840365.
- [16] Sang Won Bae and Inbok Lee. On finding a longest common palindromic subsequence. Theoretical Computer Science, 710:29–34, 2018. doi:10.1016/J.TCS.2017.02.018.
- [17] Aranya Banerjee, Daniel Gibney, and Sharma V Thankachan. Longest common substring with gaps and related problems. In 32nd Annual European Symposium on Algorithms (ESA 2024), pages 16:1–16:18. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPIcs.ESA.2024.16.
- [18] David Becerra, Juan Mendivelso, and Yoan Pinzón. A multiobjective optimization algorithm for the weighted lcs. Discrete Applied Mathematics, 212:37–47, 2016. doi:10.1016/J.DAM.2015.11.005.
- [19] Stav Ben-Nun, Shay Golan, Tomasz Kociumaka, and Matan Kraus. Time-space tradeoffs for finding a long common substring. In Inge Li Gørtz and Oren Weimann, editors, 31st Annual Symposium on Combinatorial Pattern Matching, CPM 2020, June 17-19, 2020, Copenhagen, Denmark, volume 161 of LIPIcs, pages 5:1–5:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.CPM.2020.5.
- [20] Gary Benson, Avivit Levy, S. Maimoni, D. Noifeld, and B. Riva Shalom. Lcsk: A refined similarity measure. Theor. Comput. Sci., 638:11–26, 2016. doi:10.1016/J.TCS.2015.11.026.
- [21] Lasse Bergroth, Harri Hakonen, and Timo Raita. A survey of longest common subsequence algorithms. In Pablo de la Fuente, editor, Seventh International Symposium on String Processing and Information Retrieval, SPIRE 2000, A Coruña, Spain, September 27-29, 2000, pages 39–48. IEEE Computer Society, 2000. doi:10.1109/SPIRE.2000.878178.
- [22] Guillaume Blin, Paola Bonizzoni, Riccardo Dondi, and Florian Sikora. On the parameterized complexity of the repetition free longest common subsequence problem. Information Processing Letters, 112(7):272–276, 2012. doi:10.1016/J.IPL.2011.12.009.
- [23] Karl Bringman and Marvin Künnemann. Multivariate Fine-Grained Complexity of Longest Common Subsequence, pages 1216–1235. Society for Industrial and Applied Mathematics, 2018. doi:10.1137/1.9781611975031.79.
- [24] Karl Bringmann, Vincent Cohen-Addad, and Debarati Das. A linear-time n-approximation for longest common subsequence. ACM Trans. Algorithms, 19(1):9:1–9:24, 2023. doi:10.1145/3568398.
- [25] Karl Bringmann and Marvin Künnemann. Quadratic conditional lower bounds for string problems and dynamic time warping. In 2015 IEEE 56th Annual Symposium on Foundations of Computer Science, pages 79–97. IEEE, 2015. doi:10.1109/FOCS.2015.15.
- [26] Mauro Castelli, Riccardo Dondi, Giancarlo Mauri, and Italo Zoppis. Comparing incomplete sequences via longest common subsequence. Theoretical Computer Science, 796:272–285, 2019. doi:10.1016/J.TCS.2019.09.022.
- [27] Wun-Tat Chan, Yong Zhang, Stanley PY Fung, Deshi Ye, and Hong Zhu. Efficient algorithms for finding a longest common increasing subsequence. Journal of Combinatorial Optimization, 13(3):277–288, 2007. doi:10.1007/S10878-006-9031-7.
- [28] Panagiotis Charalampopoulos, Pawel Gawrychowski, and Karol Pokorski. Dynamic longest common substring in polylogarithmic time. In Artur Czumaj, Anuj Dawar, and Emanuela Merelli, editors, 47th International Colloquium on Automata, Languages, and Programming, ICALP 2020, July 8-11, 2020, Saarbrücken, Germany (Virtual Conference), volume 168 of LIPIcs, pages 27:1–27:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.ICALP.2020.27.
- [29] Panagiotis Charalampopoulos, Tomasz Kociumaka, Solon P. Pissis, and Jakub Radoszewski. Faster algorithms for longest common substring. In Petra Mutzel, Rasmus Pagh, and Grzegorz Herman, editors, 29th Annual European Symposium on Algorithms, ESA 2021, September 6-8, 2021, Lisbon, Portugal (Virtual Conference), volume 204 of LIPIcs, pages 30:1–30:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ESA.2021.30.
- [30] Debkumar Chowdhury, Kartik Sau, and Sanjukta Mishra. A new dna sequencing alignment methodology using the longest common subsequence technique. American Journal of Applied Mathematics and Computing, 1(3):5–9, 2020.
- [31] Maxime Crochemore, Costas S. Iliopoulos, Alessio Langiu, and Filippo Mignosi. The longest common substring problem. Mathematical Structures in Computer Science, 27(2):277–295, 2017. doi:10.1017/S0960129515000110.
- [32] Maxime Crochemore and Ely Porat. Fast computation of a longest increasing subsequence and application. Information and Computation, 208(9):1054–1059, 2010. doi:10.1016/j.ic.2010.04.003.
- [33] Lisa De Mattéo, Yan Holtz, Vincent Ranwez, and Sèverine Bérard. Efficient algorithms for longest common subsequence of two bucket orders to speed up pairwise genetic map comparison. Plos one, 13(12):e0208838, 2018.
- [34] Sebastian Deorowicz and Szymon Grabowski. Efficient algorithms for the longest common subsequence in k-length substrings. Inf. Process. Lett., 114(11):634–638, 2014. doi:10.1016/J.IPL.2014.05.009.
- [35] Thomas Derrien, Jordi Estellé, Santiago Marco Sola, David G Knowles, Emanuele Raineri, Roderic Guigó, and Paolo Ribeca. Fast computation and applications of genome mappability. PloS one, 7(1):e30377, 2012.
- [36] Marko Djukanovic, Günther R Raidl, and Christian Blum. Anytime algorithms for the longest common palindromic subsequence problem. Computers & Operations Research, 114:104827, 2020. doi:10.1016/J.COR.2019.104827.
- [37] Lech Duraj, Marvin Künnemann, and Adam Polak. Tight conditional lower bounds for longest common increasing subsequence. Algorithmica, 81:3968–3992, 2019. doi:10.1007/S00453-018-0485-7.
- [38] David Eppstein, Zvi Galil, Raffaele Giancarlo, and Giuseppe F Italiano. Sparse dynamic programming i: linear cost functions. Journal of the ACM (JACM), 39(3):519–545, 1992. doi:10.1145/146637.146650.
- [39] Martin Farach-Colton, Paolo Ferragina, and Shanmugavelayutham Muthukrishnan. On the sorting-complexity of suffix tree construction. Journal of the ACM (JACM), 47(6):987–1011, 2000. doi:10.1145/355541.355547.
- [40] Effat Farhana and M Sohel Rahman. Doubly-constrained LCS and hybrid-constrained LCS problems revisited. Information Processing Letters, 112(13):562–565, 2012. doi:10.1016/J.IPL.2012.04.007.
- [41] Tomás Flouri, Emanuele Giaquinta, Kassian Kobert, and Esko Ukkonen. Longest common substrings with k mismatches. Information Processing Letters, 115(6-8):643–647, 2015. doi:10.1016/J.IPL.2015.03.006.
- [42] Darya Frolova, Helman Stern, and Sigal Berman. Most probable longest common subsequence for recognition of gesture character input. IEEE Transactions on Cybernetics, 43(3):871–880, 2013. doi:10.1109/TSMCB.2012.2217324.
- [43] Mitsuru Funakoshi, Yuto Nakashima, Shunsuke Inenaga, Hideo Bannai, and Masayuki Takeda. Faster queries for longest substring palindrome after block edit. In 30th Annual Symposium on Combinatorial Pattern Matching (CPM 2019), pages 27:1–27:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. doi:10.4230/LIPIcs.CPM.2019.27.
- [44] Shafi Goldwasser and Dhiraj Holden. The Complexity of Problems in P Given Correlated Instances. In Christos H. Papadimitriou, editor, 8th Innovations in Theoretical Computer Science Conference (ITCS 2017), volume 67 of Leibniz International Proceedings in Informatics (LIPIcs), pages 13:1–13:19, Dagstuhl, Germany, 2017. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ITCS.2017.13.
- [45] Anna Gorbenko and Vladimir Popov. The longest common parameterized subsequence problem. Applied Mathematical Sciences, 6(58):2851–2855, 2012.
- [46] Zvi Gotthilf, Danny Hermelin, and Moshe Lewenstein. Constrained lcs: hardness and approximation. In Combinatorial Pattern Matching: 19th Annual Symposium, CPM 2008, Pisa, Italy, June 18-20, 2008 Proceedings 19, pages 255–262. Springer, 2008. doi:10.1007/978-3-540-69068-9_24.
- [47] Zvi Gotthilf and Moshe Lewenstein. Approximating constrained lcs. In International Symposium on String Processing and Information Retrieval, pages 164–172. Springer, 2007. doi:10.1007/978-3-540-75530-2_15.
- [48] Dan Gusfield. Algorithms on Strings, Trees, and Sequences - Computer Science and Computational Biology. Cambridge University Press, 1997. doi:10.1017/CBO9780511574931.
- [49] MohammadTaghi HajiAghayi, Masoud Seddighin, Saeedreza Seddighin, and Xiaorui Sun. Approximating longest common subsequence in linear time: Beating the n barrier. SIAM Journal on Computing, 51(4):1341–1367, 2022.
- [50] Daniel S Hirschberg. Algorithms for the longest common subsequence problem. Journal of the ACM (JACM), 24(4):664–675, 1977. doi:10.1145/322033.322044.
- [51] Guo-Fong Huang, Chang-Biau Yang, Kuo-Tsung Tseng, and Kuo-Si Huang. Diagonal algorithms for the longest common subsequence problems with t-length and at least t-length substrings. In Proceedings of the 37th Workshop on Combinatorial Mathematics and Computation Theory, pages 119–127, 2020.
- [52] Lucas Hui. A practical algorithm to find longest common substring in linear time. Computer Systems Science and Engineering, 15, March 2000.
- [53] James W Hunt and Thomas G Szymanski. A fast algorithm for computing longest common subsequences. Communications of the ACM, 20(5):350–353, 1977.
- [54] Costas Iliopoulos, M Sohel Rahman, and Wojciech Rytter. Algorithms for two versions of LCS problem for indeterminate strings. Journal of Combinatorial Mathematics and Combinatorial Computing, 71:155, 2009.
- [55] Costas S Iliopoulos, Marcin Kubica, M Sohel Rahman, and Tomasz Waleń. Algorithms for computing the longest parameterized common subsequence. In Combinatorial Pattern Matching: 18th Annual Symposium, CPM 2007, London, Canada, July 9-11, 2007. Proceedings 18, pages 265–273. Springer, 2007.
- [56] Costas S Iliopoulos and M Sohel Rahman. Algorithms for computing variants of the longest common subsequence problem. Theoretical Computer Science, 395(2-3):255–267, 2008. doi:10.1016/J.TCS.2008.01.009.
- [57] Costas S Iliopoulos and M Sohel Rahman. New efficient algorithms for the LCS and constrained LCS problems. Information Processing Letters, 106(1):13–18, 2008. doi:10.1016/J.IPL.2007.09.008.
- [58] Costas S. Iliopoulos and M. Sohel Rahman. A new efficient algorithm for computing the longest common subsequence. Theor. Comp. Sys., 45(2):355–371, June 2009. doi:10.1007/s00224-008-9101-6.
- [59] R. Impagliazzo and R. Paturi. On the complexity of k-SAT. J. Comput. Syst. Sci., 62(2):367–375, 2001. doi:10.1006/JCSS.2000.1727.
- [60] R. Impagliazzo, R. Paturi, and F. Zane. Which problems have strongly exponential complexity? J. Comput. Syst. Sci., 63(4):512–530, 2001. doi:10.1006/JCSS.2001.1774.
- [61] Shunsuke Inenaga and Heikki Hyyrö. A hardness result and new algorithm for the longest common palindromic subsequence problem. Information Processing Letters, 129:11–15, 2018. doi:10.1016/J.IPL.2017.08.006.
- [62] Robert W. Irving and Campbell B. Fraser. Two algorithms for the longest common subsequence of three (or more) strings. In Alberto Apostolico, Maxime Crochemore, Zvi Galil, and Udi Manber, editors, Combinatorial Pattern Matching, pages 214–229. Springer Berlin Heidelberg, 1992. doi:10.1007/3-540-56024-6_18.
- [63] Orgad Keller, Tsvi Kopelowitz, and Moshe Lewenstein. On the longest common parameterized subsequence. Theoretical Computer Science, 410(51):5347–5353, 2009. doi:10.1016/J.TCS.2009.09.011.
- [64] Tomasz Kociumaka, Jakub Radoszewski, and Tatiana Starikovskaya. Longest common substring with approximately k mismatches. Algorithmica, 81(6):2633–2652, 2019. doi:10.1007/S00453-019-00548-X.
- [65] Tomasz Kociumaka, Tatiana Starikovskaya, and Hjalte Wedel Vildhøj. Sublinear space algorithms for the longest common substring problem. In European Symposium on Algorithms, pages 605–617. Springer, 2014. doi:10.1007/978-3-662-44777-2_50.
- [66] Avivit Levy and B Riva Shalom. A comparative study of dictionary matching with gaps: limitations, techniques and challenges. Algorithmica, 84(3):590–638, 2022. doi:10.1007/S00453-021-00851-6.
- [67] Rao Li, Jyotishmoy Deka, and Kaushik Deka. An algorithm for the longest common subsequence and substring problem. Journal of Mathematics and Informatics, 25:77–81, 2023. doi:10.22457/jmi.v25a08231.
- [68] David Maier. The complexity of some problems on subsequences and supersequences. J. ACM, 25(2):322–336, April 1978. doi:10.1145/322063.322075.
- [69] Shay Mozes, Dekel Tsur, Oren Weimann, and Michal Ziv-Ukelson. Fast algorithms for computing tree lcs. Theoretical Computer Science, 410(43):4303–4314, 2009. String Algorithmics: Dedicated to Professor Maxime Crochemore on the occasion of his 60th birthday. doi:10.1016/j.tcs.2009.07.011.
- [70] Eugene W Myers. An O(ND) difference algorithm and its variations. Algorithmica, 1(1):251–266, 1986. doi:10.1007/BF01840446.
- [71] Narao Nakatsu, Yahiko Kambayashi, and Shuzo Yajima. A longest common subsequence algorithm suitable for similar text strings. Acta Informatica, 18:171–179, 1982. doi:10.1007/BF00264437.
- [72] Deena Nath, Jitendra Kurmi, and Vipin Rawat. A survey on longest common subsequence. International Journal for Research in Applied Science and Engineering Technology (IJRASET), 6:4552–4556, 2018.
- [73] Negev Shekel Nosatzki. Approximating the longest common subsequence problem within a sub-polynomial factor in linear time. CoRR, abs/2112.08454, 2021. arXiv:2112.08454.
- [74] Aviad Rubinstein and Zhao Song. Reducing approximate longest common subsequence to approximate edit distance. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1591–1600. SIAM, 2020. doi:10.1137/1.9781611975994.98.
- [75] Tatiana Starikovskaya and Hjalte Wedel Vildhøj. Time-space trade-offs for the longest common substring problem. In Combinatorial Pattern Matching: 24th Annual Symposium, CPM 2013, Bad Herrenalb, Germany, June 17-19, 2013. Proceedings 24, pages 223–234. Springer, 2013. doi:10.1007/978-3-642-38905-4_22.
- [76] Sharma V Thankachan, Alberto Apostolico, and Srinivas Aluru. A provably efficient algorithm for the k-mismatch average common substring problem. Journal of Computational Biology, 23(6):472–482, 2016. doi:10.1089/CMB.2015.0235.
- [77] Robert A. Wagner and Michael J. Fischer. The string-to-string correction problem. J. ACM, 21:168–173, 1974. doi:10.1145/321796.321811.
- [78] Lusheng Wang and Binhai Zhu. Algorithms and hardness for the longest common subsequence of three strings and related problems. In Franco Maria Nardini, Nadia Pisanti, and Rossano Venturini, editors, String Processing and Information Retrieval, pages 367–380. Springer Nature Switzerland, 2023. doi:10.1007/978-3-031-43980-3_30.
- [79] Qingguo Wang, Mian Pan, Yi Shang, and Dmitry Korkin. A fast heuristic search algorithm for finding the longest common subsequence of multiple strings. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 24, pages 1287–1292, 2010. doi:10.1609/AAAI.V24I1.7493.
- [80] Y Wang. Longest common subsequence algorithms and applications in determining transposable genes. arXiv preprint arXiv:2301.03827, 2023.
- [81] Peter Weiner. Linear pattern matching algorithms. In 14th Annual Symposium on Switching and Automata Theory (swat 1973), pages 1–11. IEEE, 1973. doi:10.1109/SWAT.1973.13.
- [82] Ryan Williams. A new algorithm for optimal 2-constraint satisfaction and its implications. Theoretical Computer Science, 348(2-3):357–365, 2005. doi:10.1016/J.TCS.2005.09.023.
- [83] Sun Wu, Udi Manber, Gene Myers, and Webb Miller. An O(NP) sequence comparison algorithm. Information Processing Letters, 35(6):317–323, 1990. doi:10.1016/0020-0190(90)90035-V.
- [84] Daxin Zhu, Lei Wang, Tinran Wang, and Xiaodong Wang. A space efficient algorithm for the longest common subsequence in k-length substrings. Theoretical Computer Science, 687:79–92, 2017. doi:10.1016/J.TCS.2017.05.015.
