You are on page 1of 2

public class Main

{
public static void main(String[] args)
{
System.out.println("Hello World");

circularq q=new circularq(5);

}
}
class circularq
{
int q[];
int f,r,size,el;
circularq(int size)
{
this.size=size;
q=new int[size];
f=0;
r=0;
}
boolean isfull()
{
if(((r+1)%(size-1))==f)
return true;
else
return false;
}
boolean isempty()
{
if(f==r)
return true;
else
return false;
}
void enq(int el)
{
if(!isfull())
{
r=(r+1)%(size-1);
q[r]=el;
System.out.println("\t"+el+"enqueued");
}
else
System.out.println("Overflow");
}
void dq()
{
if(!(isempty()))
{
f=(f+1)%(size-1);
System.out.println("\t"+el+"dequeued");
}
else
System.out.println("Underflow");
}
int qfront()
{
return q[(f+1)%(size-1)];
}
int qrear()
{
return q[r];
}
}

You might also like