Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Circular_Queue{
- int front=0;
- int rear=0;
- int N=5;
- int[] arr =new int[5];
- boolean is_empty(){
- if(front==rear) return true;
- else return false;
- }
- boolean is_full(){
- if((rear+1)%N==front) return true;
- else return false;
- }
- void push(int num){
- arr[rear]=num;
- rear++;
- if(rear==N)rear%=N;
- }
- int pop(){
- int temp=arr[front];
- front++;
- if(front==N)front%=N;
- return temp;
- }
- }
Add Comment
Please, Sign In to add comment