Lists & Stacks
Sequential node-based and array-backed linear structures provide O(1) operations at designated boundaries. Stacks enforce Last-In First-Out (LIFO) discipline; queues enforce First-In First-Out (FIFO); circular lists link tail to head for perpetual rotation; segmented lists balance contiguous cache locality with O(1) segment expansion.
Key Invariants & Rules
- Stack top is always the most recently pushed element.
- Paired-queue stacks transfer N-1 elements to expose the newest item as the last-polled element.
- Circular linked list tail pointer links back to the sentinel head, preserving O(1) append and rotate.
- Functional lists share tail structure across persistent versions without mutating existing nodes.
- Segmented list cursor advances across segment boundaries without inventing intermediate operations.
Must-Know Algorithms
Foundational structure for recursion emulation, expression evaluation, and undo buffers.
Demonstrates adapter discipline and cost transference between queue operations.
Immutability guarantee enabling safe concurrency and instant version history.
Learning Path (6 Lessons)
Self-Check & Concept Review
1. How does an array-backed stack handle growth when capacity is reached?
2. In a circular singly linked list with a sentinel head node, what does `sentinel.next == sentinel` indicate?
3. When implementing a LIFO stack using two FIFO queues, what is the cost of either push or pop?
4. What is the key property of persistent functional lists (cons, head, tail)?
5. What causes a ConcurrentModificationException during list iterator traversal?