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?

  • $\begingroup$ See here and here. I am confused by this question; if you already have suffix trees, the answer follows from their definition. $\endgroup$
    – Raphael
    Commented Aug 9, 2016 at 20:57
  • $\begingroup$ @Raphael I looked at the tag 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? $\endgroup$
    – Eff
    Commented Aug 9, 2016 at 21:23
  • $\begingroup$ See here; I think answers the question quite comprehensively. (I'm saying it follows from the definition because it's quite clear that a suffix tree has exactly one node per distinct substring.) $\endgroup$
    – Raphael
    Commented Aug 9, 2016 at 21:26
  • $\begingroup$ (These questions don't have the suffix-trees tag because they are not about suffix trees. It's often useful to use Google for finding stuff on SE.) $\endgroup$
    – Raphael
    Commented Aug 9, 2016 at 21:26
  • $\begingroup$ @Raphael Yes, those questions were not about suffix trees. I'm just saying I did actually try to look for previous questions on these problems, but I stupidly looked the wrong place :-). So I thank you for the list of similar questions. It's getting a little late, so I hope I can solve these problems tomorrow with the help of those answers. $\endgroup$
    – Eff
    Commented Aug 9, 2016 at 21:34