suffix - Exact String Matching 15-853: Algorithms in the...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 15-853 Page 1 15-853: Algorithms in the Real World Suffix Trees 15-853 Page 2 Exact String Matching • Given a text T of length m and pattern P of length n • “Quickly” find an occurrence (or all occurrences) of P in T •A N a ï v e s o l u t i o n : Compare P with T[i…i+n] for all i --- O(nm) time • How about O(n+m) time? (Knuth Morris Pratt) • How about O(m) preprocessing time and O(n) search time? 15-853 Page 3 Suffix Trees • Preprocess the text in O(m) time and search in O(n) time •I d e a : – Construct a tree containing all suffixes of text along the paths from the root to the leaves – For search, just follow the appropriate path 15-853 Page 4 Suffix Trees x a b x a c c a b a
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 15-853 Page 5 Constructing Suffix trees •N a i v e O (m 2 ) algo • For every i, add the suffix S[i . . m] to the current tree c a x b 3 a b a x c 2 x a b x a c 1 15-853 Page 6 Constructing Suffix trees •N a i v e O (m 2 ) algo • For every i, add the suffix S[i . . m] to the current tree x a b x a c c a b a x c c a x b 3 2 4 1 15-853 Page 7 Constructing Suffix trees •N a i v e O (m 2 ) algo • For every i, add the suffix S[i . . m] to the current tree x a b x a c c a b a x c c c a x b 3 c 6 5 2 4 1 15-853 Page 8 Ukkonen’s linear-time algorithm • We will start with an O(m
Background image of page 2
3 15-853 Page 9 Going from T i to T i+1 •I n t h e j th substage of stage i+1, we insert S[j. .i+1] into T
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

suffix - Exact String Matching 15-853: Algorithms in the...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online