In the linked list implementation presented in Section 4.1 .2, the current position is implemented using a

Question:

In the linked list implementation presented in Section 4.1 .2, the current position is implemented using a pointer to the element ahead of the logical current node. The more “natural” approach might seem to be to have curr point directly to the node containing the current element. However, if this was done, then the pointer of the node preceeding the current one cannot be updated properly because there is no access to this node from curr. An alternative is to add a new node after the current element, copy the value of the current element to this new node, and then insert the new value into the old current node.

(a) What happens if curr is at the end of the list already? Is there still a way to make this work? Is the resulting code simpler or more complex than the implementation of Section 4.1 .2?

(b) Will deletion always work in constant time if curr points directly to the current node?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: