Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 14
Online search problem
An online player is searching for the maximum (or minimum)
price in a sequence of prices.
At each time period i, the player obtains a price quotation pi .
Then the player must decide whether to accept pi or continue
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 13
Online Algorithms
The ski problem: buy a new pair of skis or rent a pair each
time (without knowing the future)?
An answer: rent skis until the cumulative cost of renting rst
exceeds the cost of purchasing a new pair, and then purchase a
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Randomized Algorithms
For the averagecase analysis of an algorithm, we need to assume
some probability distribution on the space of all input instances of
the problem
For sorting, we assume that all n! permutations of n numbers are
equally likely we
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 7
Approximate string matching
We want to nd approximate occurrences of the pattern in the
text. We need to dene what an approximate occurrence is. In
other words, errors.
Mismatches
though


trougf
2 mismatches
(Hamming distance)
The kmisma
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 10
Data Compression
Entropy: Given probability distribution (p1 , . . . , pn ) of events ei
(symbols or messages), entropy is a measure of quantity of
information. The more likely a message is, the less information it
contains (need less bits
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 9
Regular expression matching
The regular expressions over an alphabet are the strings over the
alphabet cfw_(, ), , , such that the following hold
, , and a character in are regular expressions.
If x and y are regular expressions, so is (xy
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 8
Two approaches for string search (given P and T )
(search func)
1. Preprocess P in O(m) time
2. Search T in O(n) time
(index data structure)
1. Preprocess T in O(n) time
2. Search for P in O(m) time
The data structure constructed by the Ah
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 4
worst case
average case
Naive
O(mn)
O(n)
KMP
O(m + n)
O(m + n)
Can we do better?
No/Yes, in the worst case. n +
cn
m
O(1) where 2 c
8
3
Yes, in the average case.
&
%
1
$
'
BoyerMoore Algorithm
Comparisons from right to left.
How to shif
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 3
Ahos survey
See what topics there are in string algorithms.
Read it as lectures cover the material.
References
&
%
1
$
'
String Matching
Input: pattern P [1.m], text T [1.n]
1. Preprocess pattern P , and produce something (nite automata)
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Analysis of Algorithms
An algorithm is a sequence of computational steps that
transform the input into the output.
It typically solves some problem.
Computer programs are more general than algorithms.
Analysis
Previously algorithms were implemente
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 6
TwoDimensional Pattern Matching
Problem: Given pattern P [1.m, 1.m] and text T [1.n, 1.n], nd all
occurrences of P in T .
Symbols from alphabet .
Can be generalized to rectangular arrays.
Applications: computer vision, multimedia systems
Korea Advanced Institute of Science and Technology
CSE 4541.561

Fall 2015
'
$
Lecture 5
Multiple keyword (pattern) matching
Bibliographic search in libraries: you give several keywords, and the
computer nds all entries containing the keywords.
Problem: Given text T and patterns P1 , P2 , . . . , Pk , nd all
occurrences of the p