0% found this document useful (0 votes)
45 views

18k-1090 18k0429 An Efficient Algorithm For LCS Problem Between Two Arbitrary Sequences

This research article proposes a new algorithm to solve the Longest Common Subsequence (LCS) problem between two arbitrary sequences. The algorithm has a space complexity of O(n+r) and time complexity of O(r + n^2), where r is the number of matches between the two sequences. It reduces the LCS problem to a Longest Increasing Subsequence problem on a transformed sequence. The algorithm is more efficient than classical algorithms for certain ranges of the number of matches r.
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

18k-1090 18k0429 An Efficient Algorithm For LCS Problem Between Two Arbitrary Sequences

This research article proposes a new algorithm to solve the Longest Common Subsequence (LCS) problem between two arbitrary sequences. The algorithm has a space complexity of O(n+r) and time complexity of O(r + n^2), where r is the number of matches between the two sequences. It reduces the LCS problem to a Longest Increasing Subsequence problem on a transformed sequence. The algorithm is more efficient than classical algorithms for certain ranges of the number of matches r.
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 5

18k-1090

18k0429

An Efficient Algorithm for LCS Problem

between Two Arbitrary Sequences

This research article explores the classic problem of Longest Common Subsequence (LCS) by
briefly describing the time and space complexities of existing algorithms in this area, and also
proposes a new algorithm with the space complexity of O(n+r) and time complexity of O(r + n^2)
time — where r is the total number of elements in the set {(i, j) | such that s1[i] = s2[j]} — for certain
ranges of r.

While generally, with the random or arbitrary number of input sequences the LCS algorithms can
be NP-hard, with the number of sequences fixed, the degree of complexity is polynomial at the
minimum. Assuming the limitation of two input sequences, this paper presents a more efficient
algorithm.

LCS is the biggest or longest subsequence that is the same for all the sequences in a collection. This
subsequence does not necessarily have to be unique or possess consecutive/contiguous places in the
original sequences (for eg. , fafa is the longest common subsequence between nfafa and fanfa). The
longest rising subsequence. “Longest Increasing Subsequence(LIS) is a subsequence of a given
sequence in which the subsequence's elements are in sorted order” (ascending order) , where the
particular subsequence is as long as possible.
This particular subsequence is never striclty consecutive or follows one after another. The longest
rising subsequence of {1, 4, 2, 3}, therefore is (1, 2, 3). LIS(seq) is a given function that returns a
set that contains all of a sequence's LISs.
If s1 = xnfafa and s2 = yfanfa, Assume there is a sequence l, whose elements are vectors in the form
of I j) for all s1[i] = s2[j] . The left half of an element of l(l[u][0]) represents the symbol's position
in s1, and the right part of the element (l[u][1]) represents the symbol's position in s2. L is ordered
in ascending order using l[u][0] as the first key and descending order using l[u][1]. Define (Iu, Ju),
(Iv, Jv) ∈ l, (Iu < Iv) ∧ (Ju Jv) <--  (Iu, Ju) < (Iu, Ju). It is a bijective mapping between LIS(l) and
LCS(s1, s2) while LIS(l) is associated with LCS(s1, s2) (s1, s2). As a result, LCS(s1, s2) is reduced
to LIS(l)[25]. The proposed algorithm reduces the LCS2 problem to a LIS problem.

Illustration Figure 1:
The Algorithm :
For the problem,

s1 = xnfafa, s2 = yfanfa, the following steps should be taken in keeping with the algorith presented
above:

Scan l from left to right.

Now for example:→ L[0] = (1, 3) has right component : 3.


→ 3+1 = 4, then s2' [4]
→ s2'[4][0] is computed, which is equal to s2' [3][0] + 1 = 1
→ s2' [4][1] is the position of (1, 3) in l
→ So, s2' [4] = (1, 0).

Algorithm Walkthrough:

Now, assume r being the number of matches between s1 and


s2 sequences:
→ Step 1 of Algorithm has time complexity of
O(max(r, n log n)) time.

→ As the length of LCS is in the degree of order of n ( O(n) ), step 3 has the
space complexity of O(r) and time complexity of O(n).
→ Step 4 consequently has time and space complexity of O(n)

These are illustrated in the following figure:


The proposed algorithm is more efficient in certain ranges of “r” compared with the
classical algorithms such as the ones proposed in: ChvatalSankof algorithm [10], Hirschberg
algorithm [11], and HuntSzymanski algorithm [15].

You might also like