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 |
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
- Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?
- How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.
- How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.
- How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.
- How to create a copy of a linked list? Write a C program to create a copy of a linked list.


