Page 520 - Computer science 868 Class 12
P. 520
8 }
9 void pushfront(int v)
10 { if(front>0 && front<rear) // inserting from front end
11 {
12 ele[front- -]=v;
13 }
14 else
15 { System.out.println("Full from front");}
16 }
17 void pushrear(int v) // inserting from rear end
18 { if(rear==cap) // if full
19 {System.out.println("Full from rear");}
20 else
21 { ele[++rear];} // increasing rear pointer by 1
22 }
23 int popfront()
24 { if(front==rear) // if empty
25 return -999;
26 else
27 { front ++; // increasing front index by 1
28 return ele[front];
29 }
30 }
31 int poprear()
32 { if(front==rear) // if empty
33 return -999;
34 else
35 { // decreasing rear index by 1
36 return ele[rear-- ];
37 }
38 }
39 void display()
40 { for(int i=front+1;i<=rear;i++)
41 { System.out.print(ele[i]+" ");}
518518 Touchpad Computer Science-XII

