How to speed up calculation of length of longest common substring?

Posted by eSKay on Stack Overflow See other posts from Stack Overflow or by eSKay
Published on 2010-04-25T21:19:26Z Indexed on 2010/04/25 21:23 UTC
Read the original article Hit count: 501

I have two very large strings and I am trying to find out their Longest Common Substring.

One way is using suffix trees (supposed to have a very good complexity, though a complex implementation), and the another is the dynamic programming method (both are mentioned on the Wikipedia page linked above).

Using dynamic programming alt text

The problem is that the dynamic programming method has a huge running time (complexity is O(n*m), where n and m are lengths of the two strings).

What I want to know (before jumping to implement suffix trees): Is it possible to speed up the algorithm if I only want to know the length of the common substring (and not the common substring itself)?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about lcs