Redian新闻
>
问一个很简单的suffix tree问题。请指点。
avatar
问一个很简单的suffix tree问题。请指点。# JobHunting - 待字闺中
g*0
1
Given two strings: s1(length n),s2(length m).
Building the suffix tree of s1 takes O(n) time. To search s2 in the suffix
tree of s1 takes O(m). Why?
For example: s1: abcde, s2: e. The tree is shown below. Shouldn't the search
time be O(n)? 弱问,what did i miss? Maybe I should ask what is data
structure of the children of a node in a suffix tree? many thanks!
|(1:abcde)|leaf
tree:|
|(2:bcde)|leaf
|
|(3:cde)|leaf
|
|(4:de)|leaf
|
|(5:e)|leaf
avatar
g*k
2
only one step to reach the leaf.
for suffix tree, the internal node provide random access, so it is constant
time to traverse the subtree along the edge "e" in this case.

search

【在 g******0 的大作中提到】
: Given two strings: s1(length n),s2(length m).
: Building the suffix tree of s1 takes O(n) time. To search s2 in the suffix
: tree of s1 takes O(m). Why?
: For example: s1: abcde, s2: e. The tree is shown below. Shouldn't the search
: time be O(n)? 弱问,what did i miss? Maybe I should ask what is data
: structure of the children of a node in a suffix tree? many thanks!
: |(1:abcde)|leaf
: tree:|
: |(2:bcde)|leaf
: |

avatar
l*a
3
呵呵,if you know suffix tree can be built in O(n) time, you should also
know that s2 can be found by traversing all children of the root node.

suffix
search

【在 g******0 的大作中提到】
: Given two strings: s1(length n),s2(length m).
: Building the suffix tree of s1 takes O(n) time. To search s2 in the suffix
: tree of s1 takes O(m). Why?
: For example: s1: abcde, s2: e. The tree is shown below. Shouldn't the search
: time be O(n)? 弱问,what did i miss? Maybe I should ask what is data
: structure of the children of a node in a suffix tree? many thanks!
: |(1:abcde)|leaf
: tree:|
: |(2:bcde)|leaf
: |

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。