A third object keeps track of where you are in the list you


Question: Suppose you have created your own Linked List class (not the java.util.LinkedList class) implemented with Nodes, each with data and next-node pointers. Furthermore, suppose you are stepping through such a list extracting the data from each node. As you step through the list, who should be responsible for keeping track of where you are in the list? There are several possibilities:

a. You (the user of the list) keep a reference to the current node, and you repeatedly follow the current node's next pointer to move on to the next node.

b The Linked List object itself keeps a reference to the current node. You can ask the list for the data in the current node, and you can ask the list to move on to the next node, which causes the list to update its reference to point to the next node.

c. A third object keeps track of where you are in the list. You ask that third object to find and return to you the data in the current node. You can also ask the third object to move on to the next node. Discuss these choices from the perspective of design elegance.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: A third object keeps track of where you are in the list you
Reference No:- TGS02580250

Expected delivery within 24 Hours