< previous page page_1073 next page >

Page 1073
if (prevPtr == NULL)
prevPtr->link = newNodePtr;
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Because prevPtr does not equal NULL, the else-clause is executed. The completed list is shown with the auxiliary variables removed.
1073-01.gif

Insert(100)
We do not repeat the first part of the search, but pick up the walk-through where prevPtr is pointing to the node whose component is 50, and currPtr is pointing to the node whose component is 90.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
while (currPtr != NULL &&
item > currPtr->component)


prevPtr = currPtr;
currPtr = currPtr->link;
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Because 100 is greater than 90, this expression is TRUE and the loop body is repeated.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
The pointer variables are advanced.
1073-02.gif

 
< previous page page_1073 next page >