ARRAYDEQUE IMPLEMENTATION IN JAVA WITH GENERICS WITHOUT USING INBUILT FUNCTIONS
USING DOUBLY LINKED LIST class NodeImplementation<E>{ Node<E> head; Node<E> tail; static class Node<E>{ E data; Node<E> next; Node<E> prev; Node(E data){ this.data=data; this.next=null; this.prev=null; } } public void toAddHead(E data){ Node<E> newNode=new Node(data); if(head==null && tail==null){ System.out.println("Deque is empty"); head=newNode; tail=newNode; } else{ Node temp=head; newNode.prev=temp; temp.next=newNode; newNode.next=null; head=newNode; } } public void toAddTail(E data){ Node<E> newNode=new Node(data); if(head==null && tail==null){ System.out.println("List is Empty."); head=newNode; tail=newNode; } else{ Node temp=tail; newNode.next=temp; temp.prev=newNode; tail=newNode; newNode.prev=null; } } public void toRemoveTail(...