Given only a pointer to a node to be deleted in a singly linked list, how do you delete it ?

Here we have to delete the node whose pointer is given, If we delete this node then pointer will not point to anything means it will be dangling pointer, So The solution to this is to copy the data from the next node into this node and delete the next node.

But if think that to be deleted node is the last node then above solution wont work , In that case we have to mark it as dummy

75 total views, 5 views today

Leave a Reply