[Subject home],
[FAQ],
[progress],
Bib',
Alg's,
C ,
Java- L.A.,
Wednesday, 24-Apr-2024 21:47:11 AEST Instructions:
Topics discussed in these lecture notes are examinable
unless otherwise indicated.
You need to follow instructions,
take more notes &
draw diagrams especially as [indicated] or
as done in lectures,
work through examples, and
do extra reading.
Hyper-links not in [square brackets] are mainly for revision,
for further reading, and for lecturers of the subject.
which can implement lookup
Tables
of `elements', e.g. numbers, words, strings, sub-strings etc.
Now, there are specialalgorithms
(below) and
data-structures
for finding sub-strings of a text string:
Problem: Given a pattern string of length `m' and
and a text string of length `n',
find ( first | all ) occurence(s)
of the pattern in the text.
NB. Usually n >> m.
Strings
. . . Rabin's algorithm.
To compute txtHashi from txtHashi-1 in O(1)-time:
patHash =
(((ord(pat[1])*3+ord(pat[2]))*3+...+ord(pat[m])
) mod p
txtHash1=
(((ord(txt[1])*3+ord(txt[2]))*3+...+ord(txt[m])
) mod p
txtHashi=
((txtHashi-1 - ord(txt[i-1])*power)*3
+ ord(txt[i+m-1])
) mod p, where i>1
[lecturer:
Run demo';
class: take note of behaviour.]
We will see later for the
Suffix-tree
data structure that
query, search time can be reduced to O(m) if
pre-processing time is O(n),
i.e. to build the suffix-tree.