

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of competitive analysis in the context of online algorithms, specifically focusing on the paging problem. The author discusses the importance of online problems in computer science and introduces the concept of competitive ratio. The document then proves that the lru (least recently used) paging algorithm is k-competitive, making it an effective solution for managing cache memory in a two-level memory system.
Typology: Slides
1 / 2
This page cannot be seen from the preview
Don't miss anything!


2
Worst-case analysis.^ n
Analyze running time as function of worst input of a given size. Average case analysis.^ n
Analyze average running time over some distribution of inputs. n^
Ex: quicksort. Amortized analysis.^ n
Worst-case bound on sequence of operations. n^
Ex: splay trees, union-find. Competitive analysis.^ n
Make quantitative statements about online algorithms. n^
Ex: paging, load balancing.
3
Paging problem: Given two-level store consisting of fast memory(cache) that can hold k pages, and slow memory that can storeinfinitely many pages.^ n
Sequence of page requests p:^ –
if page p already in cache, no cost incurred – otherwise, eject some other page q from cache and replace withp, and pay unit cost for page fault. n^
If p not in cache, which page q should you evict? n^
Most fundamental and practically important online problem in CS.
4
Competitive analysis. (Sleator-Tarjan)^ n
Algorithm A is
ρ
-competitive if there exists some constant b such
that for every sequence of inputs
σ
where OPT is optimal offline algorithm. n^
OPT = MIN: evict page whose next access is furthest away. n^
A = LRU: evict page whose most recent access was earliest
Traditional analysis completely uninformative. 3
We show LRU is k-competitive.
n^
A = LIFO: evict page brought in most recently.
LIFO can have arbitrarily bad competitive ratio.
n^
Fact: no online paging algorithm is better than k-competitive.
OPT
A^
σ
ρ
σ
5
Online Algorithm and Competitive Analysis
Theorem. LRU is k-competitive.Proof: Let
τ^
be a subsequence of
σ
on which LRU faults exactly k
times, and
τ does not contain fist access in
σ
. Let p denote page
requested just before
τ
n^
Case 1: LRU faults in sequence
τ^
on p.
-^ τ^ requests at least k+1 different pages
MIN faults at least once n^
Case 2: LRU faults on some page, say q, at least twice in
τ.
-^ τ^ requests at least k+1 different pages
MIN faults at least once
6
Online Algorithm and Competitive Analysis
Theorem. LRU is k-competitive.Proof: Let
τ^
be a subsequence of
σ
on which LRU faults exactly k
times, and
τ does not contain fist access in
σ
. Let p denote page
requested just before
τ
n^
Case 3: LRU does not fault on p, nor on any page more than once.^ –
k different pages are accessed and faulted on, none of which is p – p is in MIN’s cache at start of
τ ⇒
MIN faults at least once
0
1
1
MIN faults LRU faults k times
1 times
LRU faults^ ≤
k times
Docsity.com