Documente Academic
Documente Profesional
Documente Cultură
Subsequence
Subsequence of string S string composed
of characters i1 < i2 < < ik of S.
S = cater => ate is a subsequence.
car is a subsequence.
The empty string is a subsequence.
String/Pattern Matching
You are given a source string S.
Answer queries of the form: is the string pi a
substring of S?
Knuth-Morris-Pratt (KMP) string matching.
O(|S| + | pi |) time per query.
O(n|S| + Si | pi |) time for n queries.
String/Pattern Matching
KMP preprocesses the query string pi,
whereas the suffix tree method preprocesses
the source string S.
An application of string matching.
Genome project.
Databank of strings (gene sequences).
Character set is ATGF.
Determine if a new sequence is a substring of
a databank sequence.
sleeper
leeper
eeper
eper
per, er, and r.
sleeper
leeper
eeper
eper
per, er, and r.
abbb
5
abbbb#
b#
2
abbbb#
abbbb#
abbbb#
#
3
#
b
b
4
#
b#
abbb
5
abbbb#
2
abbbb#
b#
abbbb#
3
abbbabbbb#
12345678910
abbbb#
#
3
#
b
b
4
#
10
9
8
b#
6
1
abbb
5
1
abbbb#
abbbb#
b#
abbbb#
3
abbbabbbb#
12345678910
b
8
2
abbbb#
#
3
#
b
4
#
10
9
8
b#
6
abbbb#
abbbb#
b#
abbbb#
3
abbbabbbb#
12345678910
abbbb#
b
#
b#
6
babb
10
abbba
baba
abbbb#
abbbb#
b#
abbbabbbb#
12345678910
abbbb#
3
abbbb#
b
#
b#
6
abbbb#
10
abbbb#
abbbb#
b#
abbbabbbb#
12345678910
abbbb#
3
abbbb#
b
#
b#
6
ab
10
abbbb#
abbbb#
b#
abbbabbbb#
12345678910
abbbb#
3
abbbb#
b
#
b#
6
10
abbbb#
abbbb#
b#
abbbb#
3
abbbabbbb#
12345678910
b
5
3
abbbb#
b
#
b#
6
m=2
10
m=5