Suffix Tree - PowerPoint PPT Presentation

About This Presentation
Title:

Suffix Tree

Description:

Suffix tree T ?? ?????? S ?????? n , ??? ?? ????? ?? ????? n ???? ... singing ??? ?????? ?? ????? singing in the rain ?? ??????? I'm singing in the rain ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 39
Provided by: arb5
Category:
Tags: singing | suffix | tree

less

Transcript and Presenter's Notes

Title: Suffix Tree


1
Suffix Tree
2
Suffix Tree Definition
  • Suffix tree T ?? ?????? S ?????? n , ??? ??
    ????? ?? ????? n ???? ???????? ?-1 ?? n.
  • ??? ???? ?????? (??? ??????) ?? ????? ??? ?????
  • ?? ??? ?????? ?? ?????? ?? ???? ?? S.
  • ??? ??? ????? ??????? ????? ???? ??? ??????? ???
    ??????? ?????? ????? ???.
  • ????? ?????? ??? ??? i, ????? ?? ????????
    ???????? ?? ??? ?????? ?????? ?-i, ????? ????
    ?? S ??????? ????? ?-i.

3
?????
4
??????? ????????
  • ????? ????? P ????? m ??????? T ????? n
  • ????? ?? ?????? ?????? ???????? ?????? ???????
  • ????? ??????? ???????? ? DNA

5
????? ?????? ????? P ????? T
??? ?? ?? ???????, ?? ????, ?? aw ???? a w
y a w x a w x z
6
????? - ????
z
7
10
a
w
x
z
x
z
y
y
w
9
a
a
a
w
w
x
y
w
x
x
a
x
z
a
z
z
a
w
4
w
w
x
x
6
8
z
z
1
3
z
5
2
7
????? - ????
8
????? - ???
???? ???? 7,4,1 ??? ?? ????? ???????? ?? P ? - T
9
?????????? ??????? ?????
  • ?? P ????? ?? ?????? ?? T, ?? ??? ????? ?????
    ????? ?? ???? ????? ?? T
  • ?????? singing ??? ?????? ?? ????? singing in
    the rain ?? ??????? Im singing in the rain
  • ??? ?? P ??? ?? ?????? ?? T ??? ????? ????? ?????
    ??? ?????? ????? ?????? ???? ?????, ??? ?????? ??
    suffix Tree
  • ???????? ?? P ? T ???? ????? ????? ?????
    ??????? ?????? ?????? ? - P ?????? ???.

10
?????? ??? ????? ?????? ????? P ???? T
  • ??? ????? ???, ????
  • ???? ?????? ? p ???? ????? ?? ????? ?????
    ?????? ??? , ????
  • ??? ???? DFS ??? ??? ??? ????? ?? ????? ?????
    (???? ????? ???? ???? ?? ?????), ??? ???? ?? ????
    ? O(n).

??? ????? ???? ??????? ?? ???? ????? ?? ???
11
???????? ????? ?????? ?? ??????
  • ????? ????
  • ???? ??? ??? ???? ???? ????? (?????
    ??????? ????)
  • ????? ???????? ????? ????? ???,
    .
  • ??????
  • ???? ? - ?? ?? ??????? ????? ?? ?? ???????
    ?? S ? 1 ?? i.
  • ???? ??? ????? ?????? ?? ???? ???? 1 ?? ???,
    ??? ????? ?? ??????? S.
  • ??? ???? ???? ??? ?"? ????? ??????
    ????? ????? ?????? ??????, ??? ?????? ????? ?????
    ???? ?? (????? ????? ??
    ???? ?? ??????? ?? ??).

12
???????? ????? - ????
  • ?? ???? ?????? ??? ???? ??? (u,v) ??? ???? ??
    ???? ?????? ?? ????? ???? ???? ??? ???? ???
    ?????? ???? ????????, ????? ? w. ??? ??????
    ??????? ????? ?? ????? ???? - ?????? ?????.
  • ?? ???? ?????? ??? ????? w , ????? ?? ??? ????
    ????? ??, ????? ????? ?????? ???? ????? ?? ????
    ?????, ??? ????? ??????.

13
????? ????????? ??????
????? ????????? ?????? ??????? Sawyawxawxz
14
????? - ????
4
Sawyawxawxz
15
????? - ????
w
aw
xawxz
yawxawxz
x
7
z
6
xawxz
yawxawxz
yawxawxz
awxz
???'...
16
???? ???????? ???? ??????
  • ??????? ????????? ?? E. Ukkonen
  • ?? ????? ???????
  • ???????? On-Line
  • ????? ??? ????? ?? ?? ??? ??? ??????, ????
    ??? ?? ????? Suffix Tree ?????? ??????? ???????
    ?? ??.

17
????????? ?? Ukkonen
  • ???? ? - ?? ??? ?????? ????????
    . ?? ???? ???? ?????? ????? ?? ?? ??????,
    ???? ?? ??? ?? ?????.
  • ????? ???? ?? ?????????
  • ????????? ????? ? n ?????, ?? ?????? ? i1 ,
    ??? ???? ???? ???
  • ????? ? i1 ????? ? i1 ??????, ????? ??? ???
    ???? ??

18
High-level Ukkonen algorithm
  1. Construct tree
  2. For i from 1 to n-1 do
  3. begin phase i1
  4. for j from 1 to i1
  5. begin extention j
  6. Find the end of the path from the root
    labeled
  7. in the current tree. If needed, extand
    that
  8. path by adding character
    ,
  9. thus assuring that string
    is in the tree.
  10. end
  11. end

19
??????
????
????? ???? ??
, ??? ?????? ? j ,
???? ???? ?? ???? ?? ??? ??????, ????? ??
?? ?????? ???? ????
???.
20
???? ???????
??? ????? ??? ?????? ?????? ?????? ????.
?????? ??? ?????? ?? ?? ?????? ?? ???
???? ?????? ?? ???? ??????? ???? ???? ??
??? ??? ??? ????? ?????? ????? ?? ?? ???
, ??? ???? ????? ????? ??? ?????? ?????
?? (?? ?? ???). ????? ?? ???? ????? ???
???? ??????? ???? , ??????? ??? ??? ???
. ?? ?????? ???? ???, ?? ???? ?? ?????
???? ???? . ???? ???? ????? ?-j.
??? ????? ???? ????? ??? ?????? ????? ??
?????? ??? ? . ?????
?? ?? ???? ???.
21
????? ????? ???????
??? Saxabxb, ????? ???? ????
5
x
bx
a
4
xabx
xabx
bx
2
?????? ??????? ??????? ????
1
3
22
????
?? ???? ?? ????? ????? ????? ?????? , ?
???, ?? ?? ????? j ?? ???? ????
???, ????? ??? ???? ???,
??? ???? ???
?????
???? ???? ???? ?? ??? ?????? ?? ????? ???
????? ????? ?????, ?? ????? ?????? ??????, ???
??? ???? ???? ?????, ?? ??? - ?? ????? ?? ??????
.
23
Suffix link
??? ?????? ?????, ?? ? ??? ?? ????, ?
??? ?? ?????? (???? ????). ??? ???? ??????
??????? ????? ??? ?????? ??? , ?? ?????
???? ????? ?? ????? ????? ,
??? ????? ?- ?- ?????
suffix link
???? ?????
?? ??? ? - suffix link ? -
????? ????? ?? ???.
24
???
?? ???? ?????? ???? ?? ????? ?????
????? ??? ?????? ? j ?? ???? ?????,
??? ???? ??? ??????? 1. ????? ?????? ???
??????? ???? ???? ?????? ?? ???, ?? 2. ??????
???? ?????? ???? ?????? ?????? ? j1- ??
???? ?????.
????? ????????? ?????? ????? Suffix link ???
?????? ???? ?? ??????
25
????? ? suffix link ????? ???
????? ??????? ??????? ca ????? ????? ???????,
?????? ???? 3. ?????? ???? 4 ?? ???? ????, ?????
?? ????? ??????? a.
????? ?????? ? 31 ?? ????? ???????, ????? ?????
?????? ?? ?????? ca ???? suffix - link ?????
??????? a
26
????? ??????
  • ????????? ?? Ukkonen, ??? ???? ?????? ????
    ?????? ???? suffix link ???? ???? ?????? ????
    ????.
  • ???? ?? ?? , ?? ????? ?????? v ?? ?????
    ????? ??? ????? ???? ?- ??
    ????? ?????

27
????? ? Suffix link ????? ????
???? ????? ?? ??? ??????? ???????? ????? ? -
1. ??? ??????? ????? ????
???? ???? ?? , ?????? ????? ??????? ??????
????? ??????? ??? . ??? ????? ????? ???? ???? ??,
????? ???? ?? ?? ??? 1 ?? ??????. 2. ???
????? ?? ???? ??????? ???? ??? (????? ?
) ????? ?? . ???
?????? ???? 2 ???? ????? ?? ???? ?? . ???
????? ???, ??? ???? ?? 1 ????? v, ????? ??? ?
suffix link ?????? ???? ? , ?????? ???
???? ??? ?????? . ??? ?????? ??? ???
???? ?? ???? ????? ?? ???? ???? ??
??????, ??? ??????.
28
??????? ?????
??? ?????? ?? ??????? ? -
???? ????? ???? ????? ???? ???????
?? ??? ??????, ??? ??? ????? ???? ???
????? ??? - ???? ?????, ?? ??? ???? suffix link.
?? ???? ? ?? ?????? ?? ???? ???? ?????, ???
v ????? ?????, ????? ??? ? suffix link ?????
???? ? , ?????? ????? ??? ?????? ?????? ?
?? ????, ??? ???? ?? ?????? - ??? ???? ??????.
???? ?? ???? ?? ??? ????? ??? ????
suffix link, ????? ?? ??? ??? ???? ??? ?????
(???? ??? ???? ???? ????? ???? 3 ????), ??? ????
??? ????? ??? ????? ?????, ??? ?? ???? ?????
?????, ?? ?? ???? suffix link. ??? ???? ??????
????? ??? ??? ????? ??? ???.
29
Single extension algorithm
30
????? ????? j ???? jgt1
S(v)
v
a
bc
abcd
J-1
d
31
Skip/count
???? ? g ?? ????? ?? , ???? ? d ?? ????
?????? ?? ???? ?????? ? ?????? . ??
dltg ??? ???? ??? ????? ???? . ???? gg-d, ? hd1
, ?? ???? ????? ????? ?? ???? ?????? ?????? ?????
. ????? ?? ?? ??? ???? , ??? ?????
??? ????? ?? ??? ???? g ?? ???? ???? ?????.
?"? ????? ????? ??, ????? ???? ???? ????
????? ?????? ??? ????? ?????? ??
32
????? ???? Skip/count
???
??? suffix link ????? ?????
????? ???? ?????????, ??? ???? ?????, ????? ??
??? ??? ????? ???? ???? ?????? ??
????
?? ???? skip/count , ?? ???? ????????? ?????
???
?????
????????? ???? ?????? ? ???.
????
?? ??? ?????? ?? ??? ????????? ? - , ??
?????? ?? ?? ????? ?????? ?? ??? ???????.
33
??????
  • ????? ?????? ??? ????, ?? ??? 3 ?? ?????? ?????
    ?????? ? j, ??? ??? ????? ??? ??? ??????? ??????
    ????? ???? .
  • ????? ???? ??? ???? ???.
  • ?????, ?? ???? ????? ????????? ???? ??? ???,
    ????? ?? ?????? j, ??? ??? ?? ???? ??? ?? ???
    ????? ???? ???.
  • ?????? ???? ???, ??? ??????? ????? ???? ?? ???
    ?????? ????? ???? ?????? ???? ????? ?? ?????.

34
????? ????????? ?????? ???????
  • ???? ?? ???? ???? ?????? ??????? ??? 3 ?? ??????
  • ????? ???? ?????? ??? ????? ???? 1 ??? ??? ????,
    ???? ?? ???? ???? ?? ?"? ????? ??? ???? ???????
    ???? e, ???? ????? ???? ?? ???? .
  • ????? "e" ??????? ??? ???? ??????? ????, ????
    ???? ???????? ????.

35
????? ??????
  • ?? ???? ?????? ????? ?? ?????? ???? 1 ?? 2. ??
    ???? ? - j ?? ?????? ??????? ????? ??, ??? ??????
    ??? ????? ??? 2 ????? ??? ???, ???? ????? ?? j
    ??? (?? ???? ??????). . ???? ???, ?????
    ???? ?? ?? ??????? ?-1 ??? j , ?? ????? ?????
    ????? ???? 1, ??? ??????? ???????? ?????? ??????
    ???? j1.

36
Single phase algorithm
  • Begin
  • Explicitly compute successive extensions starting
    at pointer j until reaching the first extension
    where rule 3 applies or until all extensions are
    done in this phase.
  • When do rule 2, put j to point on the new leaf
  • Increment index e by 1.
  • end

37
??? ????? ?? ????????? ??????
  • ???? ????????? ?? Ukkonen ???? ???? ????? O(n)
  • ??????? ??????? ??? ??????? (??? 1 ???? 3) ?? ??
    ???? ?????? O(1) ???, ???? ?????? O(n) ?????
    ????????? ????. ??? ?? ???? ??????? ???? 1 ???
    ???? ???? ????. ?? ???? ? j ?? ??????? ?? ??????
    ??????? ??????? ???, ?????? ? j ??? ?????? ?????
    ????, ??? ???? ??? ??? ?? ??? ????? ??????.
    ?????? ??? n ?????, ? j ???? ?? n, ????
    ?????????? ???? ????? ?? ???? ??? ????? 2n
    ?????? ???????. ?? ??? ?????? ?? ??? ?????? ????
    ??? ????, ???? ???? ?? ????? ??????, ??? ????
    ????? ? - O(n) ????? ?? ?????????.

38
????? ????? ??????
Sabcdefabcuvw
1 2 3 4 5 6 7 8 9 10 11 12
1,3
2,3
10,12
4,6
10,12
4,6
Write a Comment
User Comments (0)
About PowerShow.com