Reading — step 1 of 5
Read
~1 min readThe Doubly-Linked List + Hash Map
Doubly-Linked List Recap
prev <-- node --> next
prev <-- node --> next
prev <-- node --> next
Each node has prev and next pointers. With a sentinel head + tail, even insertions/removals at boundaries are uniform.
python
Both operations are O(1). The "sentinel" head/tail nodes mean we don't need null checks at the boundaries.
For LRU: the most-recently-used is at the FRONT. The LRU (eviction candidate) is at the BACK (just before tail).
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…