class DoublyInsertion{ Node first,last,t; static class Node{ int data; Node next; Node prev; } void create(int a[],int n){ first = new Node(); first.data = a[0]; first.prev = null; first.next = null; last = first; for(int i=1; iLength(p)) return; if(index==0){ //head condition t = new Node(); t.data = x; t.prev = null; t.next = first; first.prev = t; first = t; } else{ for(int i=0;iLength(p)){ return -1; } if(index ==1){ first = first.next; if(first!=null) first.prev = null; x = p.data; } else{ for(int i=0; i