An improved algorithm to find the length of the longest common subsequence of two strings
暂无分享,去创建一个
Let <i>A</i> and <i>B</i> be strings of common length <i>n.</i> Define <i>LLCS</i>(<i>A, B</i>) to be the length of the longest common subsequence of <i>A</i> and <i>B.</i> Hunt and Szymanski presented an algorithm for finding <i>LLCS</i>(<i>A, B</i>) with time complexity <i>O</i>((<i>r</i> + <i>n</i>)<i>logn</i>), where <i>r</i> is the number of elements in the set {(<i>i, j</i>)|<i>A</i>[<i>i</i>] = <i>B</i>[<i>j</i>]}. In the worst case the algorithm has running time of <i>O</i>(<i>n</i><sup>2</sup><i>logn</i>). We present an improvement to this algorithm which changes the time complexity to <i>O</i>(<i>r</i> + <i>n</i>(<i>LLCS</i>(<i>A, B</i>) + <i>logn</i>)). Some experimental results show dramatic improvements for large <i>n.</i>
[1] Thomas G. Szymanski,et al. A fast algorithm for computing longest common subsequences , 1977, CACM.
[2] Daniel S. Hirschberg,et al. A linear space algorithm for computing maximal common subsequences , 1975, Commun. ACM.
[3] Amar Mukhopadhyay. A fast algorithm for the longest-common-subsequence problem , 1980, Inf. Sci..
[4] Michael J. Fischer,et al. The String-to-String Correction Problem , 1974, JACM.