Queue
Queue is a data structure in which first element inserted is the first element to come out first (FIFO).
Static queue is implemented using an array and two pointers (ends): rear and front. Elements are inserted from rear end and removed from front end.
class qu{ int rear, front; int data[]; public qu(){ rear = -1; front = 0; data = new int[10]; } public void insert(int a){ if(rear <10){ ++rear; data[rear] = a; } } public void remove(){ if(rear == -1){ System.out.println("Removed: "+data[front]); ++front; } } }