When we connect a linked list node to another node does the previous connection automatically break

3 weeks ago 20
ARTICLE AD BOX

Yes, the previous connection is automatically broken (overwritten), but the node is pointed to may still exist in memory

How it works:

node1.next = node3 #previously was node2

The printer is overwritten - node1.next now points to node3. The reference to node2 is gone from node1

The old node(node2) still exist in memory , unless there are no other references to it

Garbage collection - If nothing else points to node2, it becomes eligible for garbage collection

Changing a pointer overwrites the old value but doesn't automatically delete the object it pointed to

Read Entire Article