Assume that the following method is added to the class KWLinkedList. What does this method do? public boolean question() { if (size%2 == 1 || size < 2) return false; Node h = head; for(int i = 0; i < size/2; i++) h=h.next; Node p = head; while (h!= null) { if (! p.data.equals(h.data)) return false; p = p.next; h = h.next; } return true; } Compare the elements of the first half of the list with the second half, if any one node has the same data value, it will return false, else it will return true. Compare the elements of the first half of the list with the second half, if all the nodes have the same data values, it will return true else, it will return false. Compare the elements of the first half of the list with the second half, if all the nodes have the same data values, it will return false else, it will return true Compare the elements of the first half of the list with the second half of the list, if any one node has the same data value, it will return true, else it will return false.
Assume that the following method is added to the class KWLinkedList. What does this method do?
public boolean question()
{
if (size%2 == 1 || size < 2) return false;
Node<E> h = head;
for(int i = 0; i < size/2; i++)
h=h.next;
Node<E> p = head;
while (h!= null)
{
if (! p.data.equals(h.data)) return false;
p = p.next;
h = h.next;
}
return true;
}
-
Compare the elements of the first half of the list with the second half, if any one node has the same data value, it will return false, else it will return true.
-
Compare the elements of the first half of the list with the second half, if all the nodes have the same data values, it will return true else, it will return false.
-
Compare the elements of the first half of the list with the second half, if all the nodes have the same data values, it will return false else, it will return true
-
Compare the elements of the first half of the list with the second half of the list, if any one node has the same data value, it will return true, else it will return false.
Step by step
Solved in 2 steps with 1 images