AlgoScope

Doubly Linked List

Data structurebeginnerLinked Lists

Each node points to both neighbours, so a node can be unlinked in O(1) given only the node, as the LRU cache's moves rely on.

Decision · step 2 of 8LRU Cache: A hit moves the node to the front
1:10✓head

put 1 10: a new key with room to spare. It becomes the head, the most recently used.

Open in the player →or start at step 2

What you will see

Two arrows per link; deleting a node redirects both neighbours' pointers.

How lru cache works →

Cost

accessO(n)
searchO(n)
insert at endsO(1)
delete given nodeO(1)
SpaceO(n)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Leads to

Topics that need this one first.

Taught by the same lesson

LRU Cache covers these too, in the same run.