Skip to content
Lesson 3 of 8

Step 1 of 5 · Reading · ~1 min

Read

The 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).

Up nextCombining: Hash Map + DLLThe Doubly-Linked List + Hash Map

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…