Guest User

Untitled

a guest
Oct 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Circular_Queue{
  2. int front=0;
  3. int rear=0;
  4. int N=5;
  5. int[] arr =new int[5];
  6.  
  7. boolean is_empty(){
  8. if(front==rear) return true;
  9. else return false;
  10. }
  11.  
  12. boolean is_full(){
  13. if((rear+1)%N==front) return true;
  14. else return false;
  15. }
  16.  
  17. void push(int num){
  18. arr[rear]=num;
  19. rear++;
  20. if(rear==N)rear%=N;
  21. }
  22. int pop(){
  23. int temp=arr[front];
  24. front++;
  25. if(front==N)front%=N;
  26. return temp;
  27. }
  28. }
Add Comment
Please, Sign In to add comment