Java Reference
In-Depth Information
Display 15.22 Adding a Node to the Front of a Doubly Linked List
1 . Existing list.
null
"coat"
"shoes"
"socks"
null
head
2. Create new TwoWayNode linked to “coat”
TwoWayNode newHead = new TwoWayNode (itemName, null, head) // itemName = "shirt"
null
"shirt"
null
"coat"
"shoes"
"socks"
null
newHead
head
3 . Set backward link and set new head
head. previous = newHead;
head = newHead;
null
"shirt"
"coat"
"shoes"
"socks"
null
newHead
head
 
Search WWH ::




Custom Search