A linked list class uses a Node class with successor reference next and field element to store values. It uses a reference first to point to the first node of the list. Code to print all elements stored in the list can be written as

```
A) System.out.print(first);


B)
Node p = first;
while (p != null)
{
System.out.println(p.element);
p = p.next;
}


C)
Node p = first;
while (p != null)
System.out.println(p.next);


D)
Node p = first;
for (p!= null)
{
System.out.println(p.element);
p++;
}

```

B)
Node p = first;
while (p != null)
{
System.out.println(p.element);
p = p.next;
}

Computer Science & Information Technology

You might also like to view...

You can create a calculated field for a PivotTable by clicking the ________ icon in the Design tab of the Ribbon

Fill in the blank(s) with correct word

Computer Science & Information Technology

Hook's law says that the force required to stretch a spring is proportional to the distance stretched. If a force of 18 lb is required to stretch a spring 6 in., how much force is required to stretch the spring 15 in.?

A. lb
B. lb
C. lb
D. lb
E. lb

Computer Science & Information Technology