Thursday, March 1, 2012

Longest Repeated substring

Find the longest repeated substring in a given string.Could you find the longest repeated substring in a string that has millions of characters?


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 k 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 k descendants.

1 comment:

  1. http://shashank7s.blogspot.in/2011/06/longest-repeated-substring-eg-maximum.html

    ReplyDelete