Deletion of entire Double linked list
Simply,
head = null;
tail = null;
will not work in case of Double Linked List. The reason for this is that, we have a previous node too, which will point to the previous node even if we make head=tail=null.
So, the solution for this is that, we loop through the linked list and make all the prev=null (for each node.). Now, after this if we do head=tail=null, the entire linked list is deleted.
Note : The nodes in any linked list is deleted one by one and not vanished all at once by garbage collection.
Comments
Post a Comment