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

Please answer this if you can make the actual source code based in Java, informa

ID: 3846038 • Letter: P

Question

Please answer this if you can make the actual source code based in Java, information how to make the program is not what I need. I need the entire source code that can run in NetsBean based on Java. Programming Assignments All programs must be properly documents, follow Java coding practices, and include clear output that shows how you verified that your program works. 1. Linked Lists -Deque (Double-ended queue) Implement a nested class DoubleNode for building doubly-linked lists, where each node contains a reference to the item preceding it and the item following it in the list (null if there is no such item). Then implement methods for the following tasks: Insert at the beginning Insert at the end Remove from the beginning Remove from the end Insert before a give node Insert after a given node Remove a given node Move to front (move an object to the front) Move to end (moved and object to the end)

Explanation / Answer

import java.util.*;
import java.io.*;
class Node
{

    public int info;
    public Node next, prev;
    public Node()
    {
   next = null;
         prev = null;
         info = 0;
    }

    public Node(int a, Node b, Node c)

    {
        info = a;
        next = b;
        prev = c;

    }

    public void createNodelink(int a,Node b,Node c)

    {
        next = b;
        prev = c;
        info = a;
    }  

    public Node Link()

    {
        return info;
        return next;
        return prev;

    }

}

class linkedList

{

    public Node head;
    public Node end ;
    public int ele;

    public linkedList()

    {
        head = null;
        end = null;
        ele = 0;

    }

    public boolean Empty()

    {

        return head == null;

    }

    public int readelement()

    {
        return ele;
    }

    public void insertbgn(int val)

    {

        Node n = new Node(val, null, null);      

        if(head == null)

        {

            head = n;

            end = head;

        }

        else

        {

            head.createNodelink(n);

            n.createNodelink(head);

            head = n;

        }

        ele++;

    }

    public void insertEnd(int val)

    {

        Node n = new Node(val, null, null);      

        if(head == null)

        {

            head = n;

            end = head;

        }

        else

        {

            n.createNodelink(end);

            end.createNodelink(n);

            end = n;

        }

        ele++;

    }

    /* Function to insert element at position */

    public void insertbgn(int val , int pos)

    {

        Node n = new Node(val, null, null);  

        if (pos == 1)

        {

            insertAthead(val);

            return;

        }          

        Node ptr = head;

        for (int i = 2; i <= ele; i++)

        {

            if (i == pos)

            {

                Node tmp = ptr.Link();

                ptr.createNodelink(n);

                n.createNodelink(ptr);

                n.createNodelink(tmp);

                tmp.createNodelink(n);

            }

            ptr = ptr.Link();          

        }

        ele++ ;

    }


    public void deleteAnyPos(int pos) //begining end or middle

    {      

        if (pos == 1)

        {

            if (ele == 1)

            {

                head = null;

                end = null;

                ele = 0;

                return;

            }

            head = head.Link();

            head.createNodelink(null);

            ele--;

            return ;

        }

        if (pos == ele)

        {

            end = end.Link();

            end.createNodelink(null);

            ele-- ;

        }

        Node ptr = head.Link();

        for (int i = 2; i <= ele; i++)

        {

            if (i == pos)

            {

                Node p = ptr.Link();

                Node n = ptr.Link();

                p.createNodelink(n);

                n.createNodelink(p);

                ele-- ;

                return;

            }

            ptr = ptr.Link();

        }      

    }  


    public void display()

    {

        System.out.print(" Doubly Linked List = ");

        if (ele == 0)

        {

            System.out.print("empty ");

            return;

        }

        if (head.Link() == null)

        {

            System.out.println(head.Link() );

            return;

        }

        Node ptr = head;

        System.out.print(head.Link()+ " <-> ");

        ptr = head.Link();

        while (ptr.Link() != null)

        {

            System.out.print(ptr.Link()+ " <-> ");

            ptr = ptr.Link();

        }

        System.out.print(ptr.Link()+ " ");

    }

}


public class DoublyLinkedList

{  

    public static void main(String[] args)

    {          

        sner s = new sner(System.in);

        linkedList list = new linkedList();

        System.out.println("Doubly Linked List Test ");        

        char ch;

        do

        {

            System.out.println(" Doubly Linked List Operations ");
            System.out.println("1. check empty");

            System.out.println("2. insert at begining");

            System.out.println("3. insert at end");

            System.out.println("4. insert at position");

            System.out.println("5. delete at position");

            System.out.println("1. check empty");

         

            int choice = s.nextInt();          

            switch (choice)

            {
            case 1 :

                 System.out.println("Empty status = "+ list.Empty());

                 break;          

            case 2 :

                System.out.println("Enter integer element to insert");

                list.insert( s.nextInt() );                   

                break;                        

            case 3 :

                System.out.println("Enter integer element to insert");

                list.insertAtEnd( s.nextInt() );                   

                break;                       

            case 4 :

                System.out.println("Enter integer element to insert");

                int num = s.nextInt() ;

                System.out.println("Enter position");

                int pos = s.nextInt() ;

                if (pos < 1 || pos > list.readelement() )

                    System.out.println("Invalid position ");

                else

                    list.insertAtPos(num, pos);

                break;                                        

            case 5 :

                System.out.println("Enter position");

                int p = s.nextInt() ;

                if (p < 1 || p > list.getele() )

                    System.out.println("Invalid position ");

                else

                    list.deleteAnyPos(p);

                break;   

          
          
            default :

                System.out.println("Wrong Entry ");

                break;

            }  

            list.display();

            System.out.println(" Do you want to continue y or n ");

            ch = s.next().charAt(0);  

        } while (ch == 'Y'|| ch == 'y');             

    }

}