Jump to content

Longest repeated substring problem

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 89.77.223.127 (talk) at 14:19, 27 April 2009 (Undid revision 283886957 by 136.152.145.196 (talk)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The longest repeated substring problem is finding the longest substring of a string that occurs at least twice. This problem can be solved in linear time and space by building a suffix tree for the string, and finding the deepest internal node in the tree. The string spelled by the edges from the root to such a node is a longest repeated substring. The problem of finding the longest substring with at least occurrences can be found by first preprocessing the tree to count the number of leaf descendants for each internal node, and then finding the deepest node with at least descendants.


  • Allison, L. "Suffix Trees". Retrieved 2008-10-14.