Reversing Linked Lists In these diagrams, the previous node is magenta. the current node is orange. the next node is cyan.
Since we start with the head of the list, the previous node is null. The current node is the head of the list, A, and A’s next node is B.
At each step, we set the current node’s next edge to be the previous node. So to start, that means A’s next node is now null. Then we advance the previous node to the current node, the current node to the next node, and the next node to the next node’s next node.
Repeating the process, we set D’s next node to C: Since the next node (cyan) is null, D is the new head, and we’re done!