I've noticed that a lot of code online for the remove node or delete node function of a singly LinkedList
merely set the previous node's next to the next of the node to be removed. But isn't that an incomplete deletion, because the deleted node is still pointing to it's next?
For example
A->B->C
If you delete B
, you should make A
point to C
. But if you don't make B
point to null
, doesn't B
still exist because it's pointing to C
?
Like wise, for a doubly linkedList in java, if you were deleting a node wouldn't you need to make sure that the node is no longer pointing to anything for it to be truly deleted?