Professional Documents
Culture Documents
int a;
node next;
node prev;
node(int y)
a=y;
}}
class doubleendqueue1
node top;
node front;
node temp;
void doubleendqueue1()
top=null;
front=null;
void addlast(int h)
temp=new node(h);
if(top==null)
top=temp;
front=temp;
else
top.next=temp;
temp.prev=top;
top=temp;
}}/////_________________________1
void addfirst(int h)
temp=new node(h);
if(front==null)
top=temp;
front=temp;
else
temp.next=front;
front.prev=temp;
front=temp;
}}////////_____________________2
void deletefirst()
{
try
node fr=front;
front.next.prev=null;
front=front.next;
fr=null;
catch(NullPointerException j)
front=null;
void deletelast()
try
node ls=top;
top.prev.next=null;
top=top.prev;
ls=null;
catch(NullPointerException c)
{
front=null;
void check_front()
if(front==null)
System.out.println("is empty");
else
}}
void check_top()
if(top==null)
System.out.println("is empty");
else
}
void print()
node r=front;
while(r!=null)
System.out.println(r.a);
r=r.next;
b.addfirst(1);
b.addfirst(2);
b.addfirst(3);
b.addfirst(30);
b.addfirst(377);
b.addlast(4);
b.addlast(48);
b.addlast(12);
b.deletefirst();
b.deletefirst();
b.deletelast();
b.deletefirst();
b.deletefirst();
b.check_front();
b.check_top();
b.print();