Skip to main content

Delete a node in a Doubly Linked List

Assume that linked list contains the N nodes of integers and we our deleting a node of this linked list by using of node value. In this post are given a solution of this problem , How to delete a linked list node which are contain the value X.

Test Cases : Before write an algorithm consider the following test cases.

1) When linked list are empty in this case not possible to delete any node, so display valid message (like linked list is empty).

When Linked list are not empty then iterate linked list node and find delete node value. In case we are find deleted node then there is two possibility.

2) This deleted node may be first node of linked list, In this situation head node are visiting to next upcoming nodes, If this new head is not NULL then set this previous pointer fields is NULL.

When deleted node is not head node then that is second situation. in this cases delete this node after changes previous and next node pointer position.

3) When deleted node are not exist in linked list then display message like (given deleted node are not exist!).

4) When more than two deleted node are possible Then remove the first found element.

Linked List: 1->2->3->2->5->NULL
remove=2
After delete: 1->3->2->5->NULL

Suppose we are inserted the following ( 6,9,1,4,3,6,2) node in a sequence.

Given 
Doubly Linked List Delete node value 4

Here given code implementation process.





Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment