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: 3724324 • 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. Please write out your answer in java code format

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

/*Singleton class is a class in which we can create only one instance at a time.To make a class singleton ,make the constructor of the linked list class private.and create a getInstance method which will check whether the object is null.if null create a new object or else just return the same object.Also implement an empty interface to check if the class is a singleton or not.template is shown below .Here singleton is an empty interface.*/

//method to check whether list is singleton or not

private static boolean isSingleton(Node<E> node){

       if(node instanceof singleton)
           System.out.println("Singleton");
           else
           System.out.println("Not singleton");
       return false;
         
   }

//Method to check if all values in a list is even or not
private static boolean allEven(Node<E> node){
   while (node != null)
   {
       if(!((node.getValue()%2)==0))
       break;
   node = node.getNext();
   }
       if(node==null)
       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