Assume that we have some efficient way of creating a suffix tree of a string. Then I'm interested in efficient ways of finding:
Length of longest repeated substring. Given some string $S$, then a repeated substring is a substring $R$ of $S$ that occurs more than once in $S$. Then I wish to find the length of the longest repeated substring.
Example. Consider the string yabbadabbado
, then the substring abbad
occurs twice and is the longest repeated substring, so the answer would be $5$.
I'm also interested in the similar problem by shared substring of two strings.
Length of longest common substring. Given strings $S_1$ and $S_2$ then a substring is a common substring if it is a substring of both $S_1$ and $S_2$. I wish to find the length of the longest common substring.
Example. Given strings oompaloompa
and boom
have longest common substring of oom
and hence the answer would be $3$.
How can these be found efficiently?
suffix-trees
and didn't find those questions. It's actually not quite that I already have them as suffix trees, but I have some efficient blackbox algorithm for creating the suffix trees.I am just trying to learn about suffix trees on my own, so I'm totally new to them, so that's why this question might seem quite silly. How exactly do the answers follow from their definition?
– Eff Aug 09 '16 at 21:23