Question: 1. We developed Java code for traversing a linked list. Here are several alternate, possibly lawed, approaches for using a traversal to print the contents

1. 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; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!