Skip to content

Linked List: Insertion

Task: Insert 25 between 20 and 30

head1020304025∅COST25now in the list2 pointer writes, 0 values moved

What you are watching

Inserting into a linked list moves nothing. The new node is allocated wherever there is room - drawn below the row, because its position in memory has nothing to do with its position in the list - and two pointers are rewritten: the new node points at 30, then 20 points at the new node. The order of those two writes is not optional.