23-07-2012, 01:28 PM
Tries
Tries.ppt (Size: 446 KB / Downloads: 127)
Preprocessing Strings
Preprocessing the pattern speeds up pattern matching queries
After preprocessing the pattern, KMP’s algorithm performs pattern matching in time proportional to the text size
If the text is large, immutable and searched for often (e.g., works by Shakespeare), we may want to preprocess the text instead of the pattern
A trie is a compact data structure for representing a set of strings, such as all the words in a text
A tries supports pattern matching queries in time proportional to the pattern size
Analysis of Standard Tries
A standard trie uses O(n) space and supports searches, insertions and deletions in time O(dm), where:
n total size of the strings in S
m size of the string parameter of the operation
d size of the alphabet
Compressed Tries
A compressed trie has internal nodes of degree at least two
It is obtained from standard trie by compressing chains of “redundant” nodes
Analysis of Suffix Tries
Compact representation of the suffix trie for a string X of size n from an alphabet of size d
Uses O(n) space
Supports arbitrary pattern matching queries in X in O(dm) time, where m is the size of the pattern
Can be constructed in O(n) time