February 2014
Beginner
1248 pages
62h 25m
English
Method insertAtBack (lines 69–75 of Fig. 21.3) places a new node at the back of the list. The steps are:
1. Call isEmpty to determine whether the list is empty (line 71).
2. If the list is empty, assign to firstNode and lastNode the new ListNode that was initialized with insertItem (line 72). The ListNode constructor at lines 13–16 calls the constructor at lines 20–24 to set instance variable data to refer to the insertItem passed as an argument and to set reference nextNode to null.
3. If the list is not empty, line 74 links the new node into the list by assigning to lastNode and lastNode.nextNode the reference to the new ListNode that was initialized with insertItem. ListNode’s constructor (lines 13–16) sets ...
Read now
Unlock full access