Friday, 18 January 2013

Circular Queue


By on 03:10

Circular Queue in data structure are those queue which has a circled shape.Like a circle every rear element joins the front end of node.Circular Queue is used in c,c++,java,c# etc.


Circular Queue Diagram

Example/implementation/algorithm of circular queue(Program of array):-




void insert()
{
if(f!=0 && r==50)
{
flag=0;
r=0;
q[r++]=x;
}
elseif((f==r && r==50)//(flag==0 && f==r))
cout<<"Queue is Full";
else
q[r++]=x;
}
int delete()
{
if(f==50)
{flag==1;
f==0;
}
elseif(flag==1 && f==r)
{
cout<<"Queue is Empty";
f=r=0;
}
else return q[f++];
}
void disp()
{
if(flag==1)
{
for(i=f;i<r;i++)

cout<<q[i];
else

for(i=f;i<50;i++)
cout<<q[i];
for(i=0;i<r;i++)
cout<<q[i];
}
}


That's all about Circular Queue in computer science.


If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...