由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问一个很简单的suffix tree问题。请指点。
相关主题
两个有点难度很有意思的题Longest common string问题
这个Binary Tree的题来看看用suffix tree 实现从string中找某些substring的算法 ?
问道题问道老题
请教find number of duplicates in a binary search tree问个老问题 Longest palindrome in a string
借人气问一道Samsung的题问道题: numbers of distinct substring
问下求最大回文的详细解法这道FB题怎么做?
Find number of subtrees with the same value一道binary tree的面试题求解
问一道n-ary tree 的题目这道题什么意识?
相关话题的讨论汇总
话题: suffix话题: tree话题: leaf话题: s1话题: s2
进入JobHunting版参与讨论
1 (共1页)
g******0
发帖数: 221
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
g*****k
发帖数: 623
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
: |

l*****a
发帖数: 559
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
: |

1 (共1页)
进入JobHunting版参与讨论
相关主题
这道题什么意识?借人气问一道Samsung的题
一道gg面经题问下求最大回文的详细解法
amazon一道面试题Find number of subtrees with the same value
今天上一题问一道n-ary tree 的题目
两个有点难度很有意思的题Longest common string问题
这个Binary Tree的题来看看用suffix tree 实现从string中找某些substring的算法 ?
问道题问道老题
请教find number of duplicates in a binary search tree问个老问题 Longest palindrome in a string
相关话题的讨论汇总
话题: suffix话题: tree话题: leaf话题: s1话题: s2