You can't delete the last node from a singly linked list if all you have is a pointer to that node. The previous node has a pointer to the deleted node, and there is no way for you to get there to set it to NULL. Sometimes this is addressed by having a "deleted" flag in each node. If you set that flag, the list accessors can skip over that node when traversing the list. The list can later be cleaned up and deleted nodes removed. Don
On Sep 5, 6:59 am, "$hr! k@nth" <srithb...@gmail.com> wrote: > Hi guyz, > > *Given only a pointer to a node to be deleted in a singly linked list, how > do you delete it?* > > if that node is in between the list, we can copy the data from next node > into this node and we can delete the next node. > what if the node to be deleted is last node ?? > if the list is circular linked list, does it make any difference?? > > -- > Regards, > $hr!k@nth -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.