Longest common subsequence: Difference between revisions

m
Clarified contrast between comparable vs. incomparable tuples.
m (Simplified Rick's time bound. Made additional editorial improvements.)
m (Clarified contrast between comparable vs. incomparable tuples.)
Line 14:
If i1 <= j1 and i2 >= j2 (or i1 >= i2 and i2 <= j2) then ''neither'' m1 < m2 ''nor'' m1 > m2 are possible; and m1, m2 are ''incomparable''.
 
Defining (#) to denote this case, we write m1 # m2. ''Note:''Because Thisthe includesunderlying theproduct possibilityorder thatis strict, m1 == m2, (''i.e.'', that i1 == i2 and j1 == j2) implies m1 # m2.
 
We write m1 <> m2 to mean that ''either'' m1 < m2 ''or'' m1 > m2 holds, ''i.e.'', that Thusm1, m2 are ''comparable''. Thus the (<>) operator is the inverse of (#). In this case, m1 != m2, ''i.e.'', each of tuples differ in some component.
 
Because the product order is strict, m1 <> m2 implies m1 != m2, ''i.e.'', that the tuples differ in some component.
 
Given a product-order over the set of matches '''M''', a chain '''C''' is any subset of '''M''' where m1 <> m2 for every pair of distinct elements m1 and m2 of '''C'''.
Line 22 ⟶ 24:
Finding an '''LCS''' can then be restated as the problem of finding a chain of maximum cardinality p over the set of matches '''M'''.
 
The set of matches '''M''' can be visualized as an m*n bit matrix, where each bit '''M[i, j]''' is True iff therethe isordered apair match(i, atj) theis correspondingin positions of strings ''A'' andthe ''B''set.
 
Then any chain '''C''' can be visualized as a strictly increasing curve through those match bits which are set to True.
 
'''Background'''
159

edits