For a non-empty linked list, select the code that should appear in a function that adds a node to the end of the list. newPtr is a pointer to the new node to be added, and lastPtr is a pointer to the current last node. Each node contains a pointer nextPtr, a link to a node.

a)
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;
b)
lastPtr = newPtr;
lastPtr->nextPtr = newPtr;
c)
newPtr->nextPtr = lastPtr;
lastPtr = newPtr;
d)
lastPtr = newPtr;
newPtr->nextPtr = lastPtr;

a)
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;

Computer Science & Information Technology

You might also like to view...

The ________is small blocks of memory located directly on and next to the CPU chip

a. ALU b. cache c. RAM d. buffermultiple choice

Computer Science & Information Technology

In the recursive solution to the Eight Queens problem, the problem size decreases by ______ at each recursive step.

a) one square b) two squares c) one column d) two columns

Computer Science & Information Technology