Problem statement Given a linked list and a node value, delete given node from linked list. Analysis To delete a node from linked list, first we need to find the node. We compare given value with each node of list and when value matches, we have found the node. To delete node, we need to make next pointer of previous node to point to next node of current node. However, we don't have any access to previous node of the linked list once we have moved forward. So what shall we do? We should keep track of previous node while traversing the linked list forward.
Read full article from Algorithms and Me: Linked List : Delete a given node from linked list
No comments:
Post a Comment