Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are asked to implement the following private and static methods. These metho

ID: 3724283 • Letter: Y

Question

You are asked to implement the following private and static methods. These methods are added to the class SingleLinkedList. Unless otherwise stated, you may freely copy the list provided as argument. Also, you may use helper methods if you feel the need to.

Exercise 1 boolean isSingleton (Node node) that returns a boolean indicating whether the list that starts at node is a singleton list or not Exercise 2 boolean allEven (Node node) that returns a boolean indicating whether all the integers in the list are even

Explanation / Answer

1> boolean isSingleton(Node<E> node)

{

if(node.next==null)

return true;

else

return false;

}

2.>boolean allEven(Node<Integer> node)

{

Node<Integer> temp;

temp=node;

int flag=0;

while(temp.next!=null)

{

if((temp.data%2)!=0)

{

flag=1;

break;

}

}

if (flag==0)

return true;

else

return false;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote