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

October 28, 2007 · Filed Under C Interview Questions, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

This is a very good interview question

The solution to this is to copy the data from the next node into this node and delete the next node!. Ofcourse this wont work if the node to be deleted is the last node. Mark it as dummy in that case. If you have a Circular linked list, then this might be all the more interesting. Try writing your own C program to solve this problem. Having a doubly linked list is always better.

Related Articles


Get Latest JobsAdda.com Jobs, news & updates  via Email