AlgoScope

Insert at Tail

Walk to the last node and attach the new node after it.

Linked list algorithms, algorithm, beginner
2's next now points to the new node 9.51429head
2's next now points to the new node 9.51429head

Singly Linked List: Insert at the tail

Step, step 5 of 6

2 is the last node: point its next at the new node 9.

How singly linked list works

Cost

Best
O(1)
Average
O(n)
Worst
O(n)
Space
O(1)

O(1) with a tail pointer.

Taught by the same lesson

Singly Linked List covers these too, in the same run.