开发者

Why the complexity of occurency in suffix tree is O(mn)?

Based on this http://www.itu.dk/courses/AVA/E2005/StringIndex开发者_StackOverflow中文版ing.pdf on page 12/36

Given a string T[1...n], we build a suffix tree. The search pattern is P[1...m].

• Preprocessing: O(n^2)
• Space: O(n^2)
• Occur(P in suffix tree): O(n*m) <===== why?
• Member is: O(m)


The Occur(...) operation in the material you refer to is not about searching for P from the suffix tree, but about finding longest matches (i.e. find the longest substring of P that occurs in the search tree) and report the corresponding leaves. It is worst case O(nm) operation because you need to take every suffix of P (that's O(m)) and possibly report O(n) leaves every time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜