Page 521 - Computer science 868 Class 12
P. 521
42 }
43 public static void main(int s)
44 { int ch,n;
45 DeQue ob=new DeQue(s);
46 Scanner sc=new Scanner(System.in);
47 do
48 {System.out.println("1.Push rear \n 2.Push front \n 3.Pop front \n 4.Pop rear
\n 5.Display \n 6.Exit \n");
49 System.out.println("Enter choice");
50 ch=sc.nextInt();
51 switch(ch)
52 { case 1:
53 System.out.println("Enter number");
54 n=sc.nextInt();
55 ob.pushrear(n);
56 break;
57 case 2:
58 System.out.println("Enter number");
59 n=sc.nextInt();
60 ob.pushfront(n);
61 break;
62 case 3:
63 n=ob.popfront();
64 if(n==-999)
65 System.out.println("Dequeue empty");
66 else
67 System.out.println(n+" removed from front");
68 break;
69 case 4:
70 n=ob.poprear();
71 if(n==-999)
72 System.out.println("Dequeue empty");
73 else
74 System.out.println(n+" removed from rear");
75 break;
519
Data Structures 519

