projevt

package DSProject;public class OurLinkedList  {    private Node Rootnode;        public void InsertNode(int data){        Node Newnode = new Node();        Newnode.dataitem = data;               if(Rootnode==null){            Rootnode = Newnode;        }        else {             Node Currentnode = Rootnode;        while(Currentnode.Nextnode!=null && Currentnode.dataitem!=data)        {            Currentnode = Currentnode.Nextnode;        }        if(Currentnode.Nextnode == null && Currentnode.dataitem!=data)        {               Currentnode.Nextnode = Newnode;                Newnode.Nextnode = null;        }       else        {                     while(Currentnode.Nextdown!=null){                Currentnode = Currentnode.Nextdown;            }            Currentnode.Nextdown = Newnode;            //Newnode.Nextdown = null;        }               }            }        /*public void DisplayList(){           Node Currentnode = Rootnode;        while(Currentnode!=null)               {                   Node Currentnode1=Currentnode;               while(Currentnode1!=null){                   System.out.print(Currentnode1.dataitem+” “);                   Currentnode1 = Currentnode1.Nextdown;               }                System.out.println();              Currentnode = Currentnode.Nextnode;               }             System.out.println(“NULL”);            }*/    public void Displaying(){                   Node Currentnode = Rootnode;        while(Currentnode!=null)               {                   Node Currentnode1=Currentnode;               while(Currentnode1!=null){                   System.out.print(Currentnode1.dataitem+” “);                   Currentnode1 = Currentnode1.Nextnode;               }                System.out.println();              Currentnode = Currentnode.Nextdown;               }             System.out.println(“NULL”);            }           public void remove(int dataitem){        Node CurrentNode = Rootnode;        Node PervNode = null;        while(CurrentNode!=null){            if(CurrentNode.dataitem==dataitem){                if(CurrentNode.Nextdown!=null){                    CurrentNode.Nextdown = CurrentNode.Nextdown.Nextdown;                }                PervNode = CurrentNode;                CurrentNode = CurrentNode.Nextnode;            }            CurrentNode = CurrentNode.Nextnode;        }     }        public void removeall(int dataitem){           if(Rootnode!=null){               if(Rootnode.dataitem==dataitem){                   Rootnode = Rootnode.Nextnode;           }           else{                    Node CurrentNode = Rootnode;                    Node PervNode = null;            while(CurrentNode!=null && CurrentNode.dataitem!=dataitem){                    PervNode = CurrentNode;                    CurrentNode = CurrentNode.Nextnode;                }            if(CurrentNode==null){                 System.out.println(“Linked List is Empty”);}            else            {                PervNode.Nextnode = CurrentNode.Nextnode;            }        }}        }        public boolean Contain(int dataitem){            Node CurrentNode = Rootnode;            while(CurrentNode!=null){                if(CurrentNode.dataitem==dataitem)            {return true;}                CurrentNode = CurrentNode.Nextnode;            }        return false;}}