1. Program 10 Instructions, CS102, Prof. LoftinWrite a class SortedLinkedList which handles a sorted linked list ofintegers. In particular, there should be the following public methods:SortedLinkedList() // constructor for empty listvoid add (int m) // add a node containing m into the listString toString()The add method should insert the new node in the correct place tokeep the list sorted.2. A sample driver class and outputHere is a sample driver class:public class Main{public static void main (String[] args){SortedLinkedList a = new SortedLinkedList();System.out.println(a);a.add(5);System.out.println(a);a.add(10);a.add(3);System.out.println(a);a.add(30);a.add(12);a.add(5);System.out.println(a);}}Here is the output of the driver class:[ ][ 5 ][ 3 5 10 ][ 3 5 5 10 12 30 ]3. How to do itModify the code for MyList.java that we discussed in class. Thething to change is the add method. Note that your code should cor-rectly add a node for a new integer in the following cases:• to an empty list• at the beginning of the list• in the middle of the list• at the end of the list12Be careful with your code. Make sure you avoid null pointer exceptions.4. Due date: December 7, 20095. How to turn it inSend your program SortedLinkedList.java as an email attachmentto
View Full Document