Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

efficient longest common subsequence algorithm library?

I'm looking for a (space) efficient implementation of an LCS algorithm for use in a C++ program. Inputs are two random access sequences of integers.
I'm currently using the dynamic programming approach from the wikipedia page about LCS. However, that has O(mn) behaviour in memory and time and dies on me with out of memory errors for larger inputs.
I have read about Hirschberg's algorithm, which improves memory usage considerably, Hunt-Szymanski and Masek and Paterson. Since it isn't trivial to implement these I'd prefer to try them on my data with an existing implementation. Does anyone know of such a library? I'd imagine since text diff tools are pretty common, there ought to be some open source libraries around?

like image 231
BuschnicK Avatar asked Sep 07 '10 13:09

BuschnicK


People also ask

Which algorithm is used for longest common subsequence?

Dynamic Programming This algorithm will print the longest common subsequence of X and Y.

Which algorithmic design strategy solves the problem of longest common subsequence?

Explanation: Both recursion and dynamic programming can be used to solve the longest subsequence problem.

How is a dynamic programming algorithm more efficient than the recursive algorithm while solving an LCS problem?

How is a dynamic programming algorithm more efficient than the recursive algorithm while solving an LCS problem? The method of dynamic programming reduces the number of function calls. It stores the result of each function call so that it can be used in future calls without the need for redundant calls.


1 Answers

When searching for things like that, try scholar.google.com. It is much better for finding scholarly works. It turned up http://www.biotec.icb.ufmg.br/cabi/artigos/seminarios2/subsequence_algorithm.pdf this document, a "survey of longest common subsequences algorithms".

like image 112
Lagerbaer Avatar answered Oct 21 '22 23:10

Lagerbaer