Professional Documents
Culture Documents
Applications
Philip Bille
Exact String Matching
a c
•Trie for S = {a, ca, cb}
•Member(P [1 . . . m] ):
Search from top. a b
!k
• Let |S| = i=1 Si .
• Member( P [1 . . . m]): O(m).
• Preprocessing: O(|S|).
• Space: O(|S|).
Tries and string indexing
• Recall: Build index for T [1 . . . n] supporting
Occur(P [1 . . . m]).
• Preprocessing: Build trie R for
{T [1..n], T [2..n], . . . , T [n]}
• Leaf corresponding to T [i..n] is labeled i.
• Occur( P [1 . . . m] ): Find longest match for P
inR . Report labels of all descendent leafs.
c a
o
S
o a
c
5
S
c a
o
4
o S
a
a 3 $
S 2
• Preprocessing: O(n )
2
• Space: O(n 2
)
• Occur(P [1 . . . m]): O(nm)
• Member is O(m).
Compressed tries
a
$
5
c
a o
$ a 4
$
c
o
a
3
$
a 5,6
$ 5
5
c
a o 5,6 3,6
a
4
$ 4
$
c
o 3,6
a 3
3
$
2
2
1
1
• String indexing.
• Exact set matching problem.
• Longest common substring.
• Frequent substring
Exact Set Matching
i l(i) substring
2 4 sand
3 3 and
4 3 and
5 2 an
Solution