Longest common subsequence: Difference between revisions
Content added Content deleted
m (Revised interpretation of M as a relation.) |
(Simplified discussion of the product-order, defining it to be non-strict in keeping with wider convention. Corrected legend.) |
||
Line 6: | Line 6: | ||
The [http://en.wikipedia.org/wiki/Longest_common_subsequence_problem '''Longest Common Subsequence'''] ('''LCS''') is a subsequence of maximum length common to two or more strings. |
The [http://en.wikipedia.org/wiki/Longest_common_subsequence_problem '''Longest Common Subsequence'''] ('''LCS''') is a subsequence of maximum length common to two or more strings. |
||
Let ''A'' |
Let ''A'' ≡ ''A''[0]… ''A''[m - 1] and ''B'' ≡ ''B''[0]… ''B''[n - 1], m < n be strings drawn from an alphabet Σ of size s, containing every distinct symbol in A + B. |
||
An ordered pair (i, j) will be |
An ordered pair (i, j) will be referred to as a match if ''A''[i] = ''B''[j], where 0 < i ≤ m and 0 < j ≤ n. |
||
Define the |
Define the [https://en.wikipedia.org/wiki/Product_order product-order] (≤) over ordered pairs, such that (i1, j1) ≤ (i2, j2) ⇔ i1 ≤ i2 and j1 ≤ j2. Defining (≥) similarly, we can write m2 ≤ m1 as m1 ≥ m2. |
||
We |
We say that m1, m2 are ''comparable'' if either m1 ≤ m2 or m1 ≥ m2 holds. If i1 < i2 and j2 < j1 (or i2 < i1 and j1 < j2) then neither m1 ≤ m2 nor m1 ≥ m2 are possible; and we say that m1, m2 are ''incomparable''. |
||
⚫ | |||
If i1 ≤ i2 and j2 ≤ j1 (or i2 ≤ i1 and j1 ≤ j2) then neither m1 < m2 nor m1 > m2 are possible; and m1, m2 are ''incomparable''. |
|||
⚫ | |||
Defining (#) to denote this case, we write m1 # m2. Because the underlying product-order is strict, m1 == m2 (''i.e.'', i1 == i2 and j1 == j2) implies m1 # m2. m1 <> m2 implies m1 ≠ m2, ''i.e.'', that the two tuples differ in some component. Thus, the (<>) operator is the inverse of (#). |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
According to [Dilworth 1950], this cardinality p equals the minimum number of disjoint antichains into which '''M''' can be decomposed. Note that such a decomposition into the minimal number p of disjoint antichains may not be unique. |
According to [Dilworth 1950], this cardinality p equals the minimum number of disjoint antichains into which '''M''' can be decomposed. Note that such a decomposition into the minimal number p of disjoint antichains may not be unique. |
||
Line 46: | Line 42: | ||
A, B are input strings of lengths m, n respectively |
A, B are input strings of lengths m, n respectively |
||
p is the length of the LCS |
p is the length of the LCS |
||
M is the set of match pairs (i, j) such that |
M is the set of match pairs (i, j) such that A[i] = B[j] |
||
r is the magnitude of M |
r is the magnitude of M |
||
s is the magnitude of the alphabet of distinct symbols in |
s is the magnitude of the alphabet Σ of distinct symbols in A + B |
||
'''References''' |
'''References''' |