Question: Assume the following method is within the SingleLinkedList class, what does it do? public void Undefined(E item1, E item2) { Node ptr = head; while
Assume the following method is within the SingleLinkedList class, what does it do?
public void Undefined(E item1, E item2)
{
Node
while (ptr != null)
{
if(ptr.data.equals(item1))
{
head = new Node
return;
}
ptr=ptr.next;
}
}
| a. | Adds a node after the last node with its data as item2, if item1 exists anywhere in the list. | |
| b. | Adds a node after the last node with its data as item2, if item1 exists as data of the first node in the list. | |
| c. | Adds a node before the first node with its data as item2, if item1 exists as data of the first node in the list. | |
| d. | Adds a node before the first node with its data as item2, if item1 exists anywhere in the list. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
