Question: Given the following method to be considered within the SingleLinkedList class, what does this method do public boolean Undefined() { Node ptr = head; if
Given the following method to be considered within the SingleLinkedList class, what does this method do
public boolean Undefined()
{
Node
if (ptr == null || ptr.next == null) return false;
E item1 = ptr.data;
while (ptr.next != null)
ptr = ptr.next;
E item2 = ptr.data;
if (item1.equals(item2)) return true;
else return false;
}
| a. | It returns true if the second element in the list and the last element in the list are equal, otherwise, it returns false. | |
| b. | It returns true if the first element in the list and the element before the last in the list are equal, otherwise, it returns false. | |
| c. | It returns true if the first element in the list and the last element in the list are equal, otherwise, it returns false. | |
| d. | It returns true if the second element in the list and the element before the last are equal, otherwise, it returns false |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
