Wednesday, September 10, 2008

The longest common substrings

http://www.mitbbs.com/article_t/JobHunting/31297586.html

给定两个字符串A和B
找出他们最长的公共子串,要求给出算法,考虑两种情况
(1)这个子串必须是连续的(即在A或B中必须连续)
(2)这个子串可以是任意的(即在A或B可以不连续)


我知道第二种情况肯定要用dynamic programming,能在O(|A|*|B|)算出结果。 问题第
一种情况,能否不用dynamic programming, 有什么直接的算法吗?


http://en.wikipedia.org/wiki/Suffix_tree
Suffix tree could solve:
Find the longest common substrings
Find all maximal pairs, maximal repeats or supermaximal repeats
Find the Lempel-Ziv decomposition
Find the longest repeated substrings
Find the most frequently occurring substrings of a minimum length
Find the shortest strings from Σ that do not occur in D
Find the shortest substrings occurring only once
Find, for each i, the shortest substrings of Si not occurring elsewhere in D

No comments: