Deletion in circular doubly linked list at endThere can be two scenario of deleting the first node in a circular doubly linked list. The node which is to be deleted can be the only node present in the linked list. In this case, the condition head → next == head will become true, therefore the list needs to be completely deleted. It can be simply done by assigning head pointer of the list to null and free the head pointer. in the second scenario, the list contains more than one element in the list, therefore the condition head → next == head will become false. Now, reach the last node of the list and make a few pointer adjustments there. Run a while loop for this purpose Now, temp will point to the node which is to be deleted from the list. Make the next pointer of previous node of temp, point to the head node of the list. make the previous pointer of the head node, point to the previous node of temp. Now, free the temp pointer to free the memory taken by the node. in this way, the last node of the list is deleted. Algorithm
Write UNDERFLOW [END OF LOOP] C FunctionOutput 1.Append List 2.Delete Node from last 3.Exit 4.Enter your choice?1 Enter the item 12 Node Inserted 1.Append List 2.Delete Node from last 3.Exit 4.Enter your choice?2 Node Deleted Next TopicDoubly Linked List |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India