<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>double ended queue | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/double-ended-queue/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Wed, 10 Mar 2010 16:55:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C++ program to implement the double ended queue using a double linked list</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-the-double-ended-queue-using-a-double-linked-list/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-the-double-ended-queue-using-a-double-linked-list/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 10 Mar 2010 16:55:38 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[deque]]></category>
		<category><![CDATA[double ended queue]]></category>
		<category><![CDATA[doubly linked list]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=998</guid>

					<description><![CDATA[<p>class node<br />
{<br />
public:<br />
int data;<br />
class  node *next;<br />
class node *prev;<br />
};</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-the-double-ended-queue-using-a-double-linked-list/">C++ program to implement the double ended queue using a double linked list</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write C++ program to implement the double ended queue ADT using a doubly linked list */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;

class node
{
public:
int data;
class  node *next;
class node *prev;
};

class dqueue: public node
{
  node *head,*tail;
  int top1,top2;
  public:
   dqueue()
   {
   top1=0;
   top2=0;
   head=NULL;
   tail=NULL;
   }
  void push(int x){
	node *temp;
	int ch;
	if(top1+top2 >=5)
	{
	  cout <<"dqueue overflow";
	  return ;
	}
	if( top1+top2 == 0)
	  {
	    head = new node;
	    head->data=x;
	    head->next=NULL;
	    head->prev=NULL;
	    tail=head;
	    top1++;
	  }
	 else
	 {
	   cout <<" Add element 1.FIRST 2.LAST\n enter ur choice:";
	   cin >> ch;


	   if(ch==1)
	   {
	     top1++;
	     temp=new node;
	     temp->data=x;
	     temp->next=head; 
	     temp->prev=NULL;
	     head->prev=temp;
	     head=temp;
	   }
	   else
	   {
	     top2++;
	     temp=new node;
	     temp->data=x;
	     temp->next=NULL;
	     temp->prev=tail;
	     tail->next=temp;
	     tail=temp;
	   }

	 }
  }
  void pop()
  {
   int ch;
   cout <<"Delete 1.First Node 2.Last Node\n Enter ur choice:";
   cin >>ch;
   if(top1 + top2 <=0)
   {
     cout <<"\nDqueue under flow";
     return;
   }
   if(ch==1)
   {
     head=head->next;
     head->prev=NULL;
     top1--;
   }
   else
   {
     top2--;
     tail=tail->prev;
     tail->next=NULL;
   }
  }

  void display()
  {
   int ch;
   node *temp;
   cout <<"display from 1.Staring 2.Ending\n Enter ur choice";
   cin >>ch;
   if(top1+top2 <=0)
   {
     cout <<"under flow";
     return ;
   }
   if (ch==1)
   {
    temp=head;
    while(temp!=NULL)
    {
      cout << temp->data <<" ";
      temp=temp->next;
    }
   }
   else
   {
    temp=tail;
    while( temp!=NULL) 
    {
      cout <<temp->data << " ";
      temp=temp->prev;
    }
   }
    }
  };

  main()
  {
    dqueue d1;
    int ch;
    while (1){
	cout <<"1.INSERT  2.DELETE  3.DISPLAU  4.EXIT\n Enter ur choice:";
    cin >>ch; 
    switch(ch)
    {
    case 1:     cout <<"enter element";
		cin >> ch;
		d1.push(ch); break;
    case 2: d1.pop(); break;
    case 3: d1.display(); break;
    case 4: exit(1);
    }
  }}
</pre>
<p><strong>OUTPUT</strong></p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT<br />
 Enter ur choice:1<br />
enter element4</p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT<br />
 Enter ur choice:1<br />
enter element5<br />
 Add element 1.FIRST 2.LAST<br />
 enter ur choice:1</p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT<br />
 Enter ur choice:1<br />
enter element6<br />
 Add element 1.FIRST 2.LAST<br />
 enter ur choice:2</p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT</p>
<p> Enter ur choice:3<br />
display from 1.Staring 2.Ending<br />
 Enter ur choice1<br />
5 4 6 </p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT</p>
<p> Enter ur choice:2<br />
Delete 1.First Node 2.Last Node<br />
 Enter ur choice:1</p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT</p>
<p> Enter ur choice:3<br />
display from 1.Staring 2.Ending</p>
<p> Enter ur choice1<br />
4 6 </p>
<p>1.INSERT  2.DELETE  3.DISPLAU  4.EXIT<br />
Enter ur choice:4</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-the-double-ended-queue-using-a-double-linked-list/">C++ program to implement the double ended queue using a double linked list</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-the-double-ended-queue-using-a-double-linked-list/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
