< previous page page_1140 next page >

Page 1140
    if (fromPtr == NULL)
        return NULL;                   // Base case
    else                               // Recursive case
    {
        toPtr = new NodeType;
        toPtr->component = fromPtr->component;
        toPtr->link = PtrToClone(fromPtr->link);
        return toPtr;
    }
}
Let's perform a code walk-through of the function call
newListHead = PtrToClone(head);
using the following list:
1140-01.gif
Call 1: fromPtr points to the node containing 49 and is not NULL. A new node is allocated and its component value is set to 49.
1140-02.gif
Execution of this call pauses until the recursive call with actual parameter fromPtr->link has been completed.
Call 2: fromPtr points to the node containing 50 and is not NULL. A new node is allocated and its component value is set to 50.
1140-03.gif

 
< previous page page_1140 next page >