The longest common substring problem according to wiki can be solved using a suffix tree.
From wiki:
The longest common substrings of a set of strings can be found by building a generalised suffix tree for the strings, and then finding the deepest internal nodes which have leaf nodes from all the strings in the subtree below it
I don't get this.
Example: if I have:ABCDE and XABCZ
then the suffix tree is (some branches from XABCZ omitted due to space):
The longest common substring is ABC but it is not I can not see how the description of wiki helps here.ABC is not the deepest internal nodes with leaf nodes.
Any help to understand how this works?
ABC is not the deepest internal nodes with leaf nodes.No, but ABC is the longest common string of nodes anywhere in the tree. The next longest ones areB-CandD-E, with two nodes each. - Robert HarveyABCis the longest common string. But I don't understand how the wiki description would actually help me find it programmatically - Cratylus