1. Engineering
  2. Computer Science
  3. 40 we developed java code for traversing a linked list...

Question: 40 we developed java code for traversing a linked list...

Question details

40. We developed Java code for traversing a linked list. Here are several alternate, possibly lawed, approaches for using a traversal to print the contents of the linked list of strings accessed through letters. Critique each of them:

a. LLNode currNode = letters;

while (currNode != null)

{

System.out.println(currNode.getInfo());

currNode = currNode.getLink();

}

b. LLNode currNode = letters;

while (currNode != null)

{

currNode = currNode.getLink();

System.out.println(currNode.getInfo());

}

c. LLNode currNode = letters;

while (currNode != null)

{

System.out.println(currNode.getInfo());

if (currNode.getLink() != null)

currNode = currNode.getLink();

else

currNode = null; }

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution