Doubly linked list
easy 16 minA doubly linked list is a chain of nodes where every node links to both its neighbours, the one before (prev) and the one after (next).
Where it shows up
The same pattern appears across everyday software.
Browser history
Visiting Google, then GitHub, then Stack Overflow, then Claude appends each page after the current one. Back follows prev to the page before, Forward follows next to the page after, and visiting a new page from the middle drops everything ahead of it.
Music playlists
Queued songs are inserted at the tail. Next follows the next pointer from the song now playing and Previous follows prev, so skipping either way is a single hop.
Undo and redo in editors
Typing, bolding, inserting an image and changing a font each become a node. Undo moves the current pointer back along prev, redo moves it forward along next, and a fresh action after an undo cuts off the redo nodes.
LRU caches
Database buffer pools, browser caches and in-memory caches pair a hash map with a doubly linked list. Java's LinkedHashMap and Python's OrderedDict keep their order with doubly linked lists, which is why they can move an entry to the end in O(1).
Operating systems
The Linux kernel's list_head is a circular doubly linked list used for process lists, timers and device queues, and Alt+Tab window switching keeps windows in most-recently-used order.
Trains
The physical version: each car is coupled to the car in front and the car behind. Cars can be added at the engine end or the caboose end, and a conductor can walk the train in either direction.