Friday, 18 January 2013

D-Queue(Double Ended Queue)


By on 07:37

D-Queue or De queue or double ended queue is a linear data type or abstract data type where insertion and deletion can be possible at either the front and rear end.It is used in c,c++,java,c# etc.

Type of Deques:-


1)I/o Restricted D-Queue(Insertion from one end but deletion from both ends).


2)O/p Restricted D-Queue(Insertion from both ends but deletion from one end).


Example/implementation/algorithm(Program for D-Queue):-




rear-->insert-->r++-->delete-->r--

front-->delete-->f++-->insert-->f--

void insert(int ch1,int x)

{
if(f==0 && r==50)
cout<<"Queue is Full";
else if(f!=0 && ch1==1)
q[--f]=x;
elseif(ch1==0 && r!=50)
q[r++]=x;
else
cout<<"Not Possible";
}
int delete(int ch1)
{
int p;
if(f==r)
{
f=r=0;
return 999;
}
elseif(ch1==1)
p=q[f++];
return p;
}
p=q[r--];
return p;
}
}
void display()
{
for(int i=f;i<r;i++)
cout<<q[i];
}
};



That's all about D Queue in data structure.


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...