Data Structures

1. In a given singly linked list if you are given only a node then how to delete this node?
As given in example if node three is given to you (no other information) then how to delete node 3 from this link list?
 1  2  3  4  5
One answer is just to copy node 4 content to node 3 and node 5 content to node 4 and delete node 5.
Now, if you are given node 5 to delete...?????? In this case it is not possible to delete node 5.

There is even one more effective way to delete this node..just delete next node of the given one and copy the content of this node to the node meant to be deleted.
Zubair Ahmad,
Jan 29, 2010, 1:06 AM
Zubair Ahmad,
Jan 29, 2010, 2:35 AM