3.25 Case Studies
This section combines multiple patterns from the chapter into complete, end-to-end linked list algorithms.
26 notes
This section combines multiple patterns from the chapter into complete, end-to-end linked list algorithms.
Linked list algorithms are dominated by pointer traversal and constant-time link updates.
Pointer code should be tested by checking structure, not only values.
Edge cases are inputs that sit near the boundary of an algorithm's assumptions.
An LRU cache stores a fixed number of key-value entries and removes the least recently used entry when capacity is exceeded.
A queue is a first-in, first-out structure.
A stack is a last-in, first-out (LIFO) structure.
An iterator is an object or procedure that visits the nodes of a linked list one at a time.
Memory ownership describes which part of a program is responsible for creating, linking, unlinking, and destroying a node.
An intrusive list stores the linkage fields inside the objects being linked.
A skip list augments a sorted linked list with multiple levels of forward pointers.
A persistent list is a list that preserves older versions after an update.
Pointer aliasing occurs when two or more references point to the same node.
A dummy head is a fixed node placed before the real head of a singly linked list.
Insertion adds nodes into a linked list by creating new links while preserving reachability of all existing nodes.
Deletion removes one or more nodes from a linked list by changing links around them.
Merging is a family of constructions that combine multiple linked lists into one or more output lists while preserving structural invariants.
Splitting a linked list means cutting one list into two or more lists while preserving the original nodes.
Merging combines two sorted singly linked lists into one sorted list by relinking nodes.
Fast and slow pointers are two references that traverse the same linked structure at different speeds.
A cycle exists in a linked list when some node’s `next` pointer eventually leads back to a previously visited node.
Reversal transforms a linked list so that the direction of all edges is flipped.
A sentinel node is an artificial node placed at the boundary of a linked list.
A doubly linked list is a sequence of nodes where each node stores a value, a reference to the next node, and a reference to the previous node.
A singly linked list is a sequence of nodes where each node stores a value and a reference to the next node.
Linked lists are the first data structure in this book where the shape of the data matters as much as the values stored inside it.