| Quick Reference Linked List CheatsheetA linked list on one page — nodes, splices, and the traps around the head, lost tails, and cycles. 10 sections 10 tables 14 code snippets A node and a headOne value, one link Walk until the end The parts
This page is a linked list. A tree is left out. What each operation costsNew front in two writes Cost from the head
Head and tailThe empty list is special Keep the two ends honest
Insert after a nodeSave the rest, then link Order of the two writes
Unlink a nodeSkip the current node Who must change
Reverse the linksSave next, then turn the link One pass, constant extra space
Slow and fastSecond middle on an even count Nth from the end Two speeds
A cycleMeet, then find the entrance Floyd uses constant extra memory
Doubly and circularMiddle node, both neighbors A second link changes the cost
Interview trapsThe rest of the list drops An array shift is not a splice A circle has no None end Traps worth memorising
How to use this page: insert at the head in O(1), set |