Linked List
Pointer surgery. Cheap inserts, no random access, and a favourite whiteboard test.
What you actually need to hold in your head
- A dummy head removes edge cases
- Fast and slow pointers find middle and cycles
- Reverse by rewiring three pointers
- Recursion mirrors the structure exactly
Watch it run
Step through the algorithm before you write it.
Three pointers, one flipped link per step. The whole trick is saving the next node before you overwrite it.
One pointer moves twice as fast. If there is a loop they must meet inside it, and resetting one to the head finds where the loop starts.
A dummy head removes every empty-list edge case. Then just attach whichever front node is smaller.
Patterns in this topic
The trigger phrases are what you are training yourself to notice.
Move one pointer at twice the speed of the other. They meet only inside a cycle, and when the fast one ends the slow one sits at the middle.
Carry three pointers, previous, current and next, and flip one link per iteration.
Linked List problems
Ordered by sheet phase, so the early ones are the highest signal.