13.07.2015 Views

New Efficient Algorithms for LCS and Constrained LCS Problem

New Efficient Algorithms for LCS and Constrained LCS Problem

New Efficient Algorithms for LCS and Constrained LCS Problem

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Algorithm 1 Alg<strong>LCS</strong><strong>New</strong>1: Construct the set M using Algorithm 1 of [24]. Let M i = {(i, j) | (i, j) ∈ M, 1 ≤j ≤ n}.2: global<strong>LCS</strong>.Instance = ɛ3: global<strong>LCS</strong>.Value = ɛ4: H 0 = ɛ5: <strong>for</strong> i = 1 to n do6: H i = H i−17: <strong>for</strong> each (i, j) ∈ M i do8: maxresult = BoundedMax(H i−1 , j)9: T [i, j].Value = maxresult.Value + 110: T [i, j].Prev = maxresult.Instance11: if global<strong>LCS</strong>.Value < T [i, j].Value then12: global<strong>LCS</strong>.Value = T [i, j].Value13: global<strong>LCS</strong>.Instance = (i, j)14: end if15: IncreaseV alue(H i , j, T [i, j].Value, (i, j)).16: end <strong>for</strong>17: Delete H i−1 .18: end <strong>for</strong>19: return global<strong>LCS</strong>where⎧1 + T [i − 1, j − 1, k − 1] if(k = 1 or⎪⎨T ′ (k > 1 <strong>and</strong> T [i − 1, j − 1, k − 1] > 0))[i, j, k] =<strong>and</strong> X[i] = Y [j] = Z[k].⎪⎩0 otherwise.(3)<strong>and</strong>⎧⎪⎨ 1 + T [i − 1, j − 1, k] if (k = 0 or T [i − 1, j − 1, k] > 0)T ′′ [i, j, k] =<strong>and</strong> X[i] = Y [j].⎪⎩0 otherwise.(4)The following boundary conditions are assumed in Equations 2 to 4:T [i, 0, k] = T [0, j, k] = 0, 0 ≤ i, j ≤ n, 0 ≤ k ≤ p.It is straight<strong>for</strong>ward to give a O(pn 2 ) algorithm realizing the dynamic programming<strong>for</strong>mulation presented in Equations 2 to 4. Our goal is to present a new efficient algorithmusing the parameter R. In line of Equation 1, we can re<strong>for</strong>mulate Equations 3<strong>and</strong> 4 as follows:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!