Java Reference
In-Depth Information
Display 15.23 Deleting a Node from a Doubly Linked List
1 . Existing list with an iterator referencing “shoes”
null
"coat"
"shoes"
"socks"
null
head
position
2. Bypass the “shoes” node from the next link of the previous node
position.previous.next = position.next;
null
"coat"
"shoes"
"socks"
null
head
position
3. Bypass the “shoes” node from the previous link of the next node
and move position off the deleted node
position. next.previous = position.previous;
position = position.next;
null
"coat"
"shoes"
"socks"
null
head
position
4. Picture redrawn for clarity with the “shoes” node removed since
there are no longer references pointing to this node.
null
"coat"
"socks"
head
position
 
Search WWH ::




Custom Search