1
CSE 421
Algorithms
Richard Anderson
Lecture 8
Optimal Caching
Dijkstra’s algorithm
Today’s Lecture
•
Optimal Caching (Section 4.3)
•
Dijkstra’s Algorithm (Section 4.4)
Optimal Caching
•
Caching problem:
– Maintain collection of items in local memory
– Minimize number of items fetched
Caching example
A, B, C, D, A, E, B, A, D, A, C, B, D, A
Optimal Caching
•
If you know the sequence of requests,
what is the optimal replacement pattern?
•
Note – it is rare to know what the requests
are in advance – but we still might want to
do this:
– Some specific applications, the sequence is
known
– Competitive analysis, compare performance
on an online algorithm with an optimal offline
algorithm
Farthest in the future algorithm
•
Discard element used farthest in the future
A, B, C, A, C, D, C, B, C, A, D
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2
Correctness Proof
• Sketch
•
Start with Optimal Solution O
•
Convert to Farthest in the Future Solution
FF
•
Look at the first place where they differ
•
Convert O to evict FF element
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '06
 RichardAnderson
 Algorithms, Graph Theory, Shortest path problem, shortest path, Dijkstra

Click to edit the document details