Download presentation
Presentation is loading. Please wait.
1
LRU is k-competitive
2
Lemma Consider a sequence of requests. LRU ejects P P Lemma: In any request sequence, if P is touched and the at some point later LRU ejects P, then even the offline algorithm has a fault between the time P is touched and when it is ejected.
3
Lemma Proof: If P is rejected by the LRU, it means right now there are in the cache k-1 pages that were accessed after P was accessed, and a new page is now being accessed – together k+1. By the pigeonhole principle, even the offline algorithm will need to eject someone in this subsequence.
4
Theorem Theorem: For any sequence segment where LRU has k faults, the offline algorithm has a fault. Proof: Consider the sequence of requests: P k LRU faults subsequence σ
5
Cases: P ejected in subsequence σ. P
P ejected by LRU P In this case, by lemma, there is one fault by offline algorithm.
6
Cases: 2. There exist a Q in σ, that is ejected twice. Q Q ejected by LRU P This means that between the first and second ejection Q had to enter the cache. In this case, by lemma, there is one fault by offline algorithm.
7
Cases: 3. P is not ejected in σ, and no one is ejected twice. P It means: Entering σ, there are k-1 pages other than P and P. k different pages are ejected, but not P. Therefore, there has to be a page that entered the cache in σ and was ejected by LRU in σ. By lemma, there is one fault by offline algorithm.
8
Conclude Every subsequence where LRU has k faults, necessarily has at least one fault by the offline algorithm. Therefore: LRU is k-competitive.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.