Linear structures
Ways to keep items in a line, and what each one makes cheap: linked lists for splicing, stacks and queues for order, deques for both ends, heaps for always knowing the biggest. Each one has a live visualizer running the real code.
- 01Deleting from a linked listUnlink nodes by moving one pointer, with nothing to shift.O(n)
- 02Reversing a linked listTurn every arrow around with three pointers in one pass.O(n)
- 03Fast and slow pointersOne pointer moves twice as fast, so the slow one stops in the middle.O(n)
- 04StackLast in, first out: check that every bracket is closed in the right order.O(n)
- 05QueueFirst in, first out: share time fairly between tasks, round robin.O(1) per step
- 06DequeAdd and remove at both ends to track the maximum of a sliding window.O(n)
- 07Binary heapPush values into a heap and watch each one sift up to its place.O(log n)