Each node knows what comes next.
Follow the links. Insert a new neighbor. Reconnect the chain. See how a singly linked list works.
Value + next pointer
HEAD is where traversal starts. TAIL is the last node; its next pointer is null. Scroll horizontally for longer lists.
head → N1 · tail → N3Values live inside nodes. The next reference connects one node to another.
Try inserting 25 at index 1, then trace the updated chain.
Follow the pointer changes.
- Your next operation will appear here.
Change the links, not every value.
Nodes do not need contiguous memory. This diagram places them in a row for readability; N1, N2, and so on are illustrative IDs, not memory addresses.
Prepend: point the new node at the old head, then move head. O(1).
Append: use the stored tail to attach a node. O(1).
Insert/delete by index: follow links to the predecessor, then reconnect. O(n) overall; changing the links is O(1).
Search/traverse: follow next from head. O(n). There is no direct array-style indexing; deleting the tail still needs its predecessor.