Lecture 6 - Online - Algorithms
Lecture 6 - Online - Algorithms
Online Algorithms
Introduction to Algorithms
Da Nang University of Science and Technology
Introduction
Online algorithms analysis
Competitive analysis
Probabilistic analysis
Motivating examples:
Ski rental problem
2-lane line search problem
Paging problem
Bélády's anomaly
Competitive analysis
An online algorithm is c-competitive if there is a constant
b for all sequences s of operations
CON(s) ≤ c COPT(s) + b
Where CON(s) is the cost of online algorithm on the sequence s
and COPT(s) is the optimal offline cost for the same sequence
Competitive ratio: The ratio between the output
generated by an online algorithm and the output produced
by an optimal offline algorithm
Probabilistic analysis
Assume a distribution generating the input then find an
algorithm which minimizes the expected cost of the online
algorithm
Intelligent Networking Laboratory DANG THIEN BINH 4/23
Ski rental problem (1/4)
Left Right
x’ O x
Figure 3. The worst case when the robot finds the object
1 ∗ 1 − 2𝑗+2
= 2∗ + 2𝑗 + 𝜀
1−2
= 2 ∗ (2𝑗+2 − 1) + 2𝑗 + 𝜀
= (23 +1) ∗ 2𝑗 + 𝜀 − 2
≈ 9 ∗ 2𝑗 + 𝜀
where j is the number of iterations and 𝜀 is a small distance
Intelligent Networking Laboratory DANG THIEN BINH 11/23
2-lane line search problem (5/5)
Continue…