circular queue using linked list in c 2b 2b

Solutions on MaxInterview for circular queue using linked list in c 2b 2b by the best coders in the world

showing results for - "circular queue using linked list in c 2b 2b"
Domenico
04 Apr 2019
1#include<iostream>
2
3#define SIZE 100
4
5using namespace std;
6
7class node
8{
9public:
10    node()
11    {
12        next = NULL;
13    }
14  int data;
15  node *next;
16}*front=NULL,*rear=NULL,*n,*temp,*temp1;
17
18class cqueue
19{
20public:
21    void insertion();
22    void deletion();
23    void display();
24};
25
26int main()
27{
28    cqueue cqobj;
29  int ch;
30  do
31  {
32     cout<<"\n\n\tMain Menu";
33     cout<<"\n##########################";
34     cout<<"\n1. Insert\n2. Delete\n3. Display\n4. Exit\n\nEnter Your Choice: ";
35     cin>>ch;
36     switch(ch)
37     {
38        case 1:
39          cqobj.insertion();
40          cqobj.display();
41          break;
42        case 2:
43          cqobj.deletion();
44          break;
45        case 3:
46          cqobj.display();
47          break;
48        case 4:
49          break;
50        default:
51          cout<<"\n\nWrong Choice!!! Try Again.";
52     }
53  }while(ch!=4);
54  return 0;
55}
56
57void cqueue::insertion()
58{
59  n=new node[sizeof(node)];
60  cout<<"\nEnter the Element: ";
61  cin>>n->data;
62  if(front==NULL)
63  {
64      front=n;
65  }
66  else
67  {
68      rear->next=n;
69  }
70  rear=n;
71  rear->next=front;
72}
73
74void cqueue::deletion()
75{
76  int x;
77  temp=front;
78  if(front==NULL)
79  {
80      cout<<"\nCircular Queue Empty!!!";
81  }
82  else
83  {
84     if(front==rear)
85     {
86       x=front->data;
87       delete(temp);
88       front=NULL;
89       rear=NULL;
90     }
91     else
92     {
93        x=temp->data;
94        front=front->next;
95        rear->next=front;
96        delete(temp);
97     }
98     cout<<"\nElement "<<x<<" is Deleted";
99     display();
100  }
101}
102
103void cqueue::display()
104{
105  temp=front;
106  temp1=NULL;
107  if(front==NULL)
108  {
109    cout<<"\n\nCircular Queue Empty!!!";
110  }
111  else
112  {
113    cout<<"\n\nCircular Queue Elements are:\n\n";
114    while(temp!=temp1)
115    {
116       cout<<temp->data<<"  ";
117       temp=temp->next;
118       temp1=front;
119    }
120  }
121}
queries leading to this page
a circular linked list is used to represent a queuecircular queue using doubly linked listcircular queue implementation using linked listqueue using circular linked listcircular queue using linked list in c 2b 2bcircular linked queue implementationcircular queue implementation in c using linked listcircular queue program in c using linked listqueue using circular linked list c 2b 2bcircular queue using doubly linked list in cimplement the queue with circular linked list in c 2b 2bcircular queue using double linked listcircular linked list is used to represent a queuequeue with circular linked list in c 2b 2balgorithm for implementation of circular queue using linked listcircular linked list vs circular queuecircular queue linked list implementationcircular queue linked list c 2b 2bcircular linked list queue in cis queue a circular linked listc program for circular queue using linked listc 2b 2b program for circular queue using linked listcircular queue using circular linked list c 2b 2bsimple queue as a circular linked listcircular queue in c 2b 2bcircular linked list implement queuecircular queue linked list implementation in cimplementation of queue using circular linked listc program to implement circular queue using linked listcircular linked queuestack using circular linked list in c 2b 2bcircular linked list in c 2b 2bcircular queue linked listcircular queue and its implementation in linked listcircular queue using linked list in ccircular queue using linked list search functioncircular queue using linked list sanfoundrycircular queue in c 2b 2b using linked listimplementation of circular queue using linked list in ccircular queue with linked list code to search element in a circular linked list c 2b 2bcircular queue using linked list c 2b 2bqueue using circular linked list c 2b 2bcircular queue using singly linked listrepresent linked list as circular queuecircular queue using linked listcircular queue and circular linked list same 3fcircular linked list queueimplement a queue using circular linked list program to implement circular queue using linked list circular queue using linked list in ca circular queue is implement using a single linked listhow to make a circularly linked list c 2b 2bcode to create circular linked list c 2b 2blinked list implementation of circular queue in chow will you represent circular linked list as queue implement circular queue using linked list in ccircular queue using linked list cqueue linked list implementation consider implementing a circular queue using a linked list why can we implement circular queue using linked listcircular queue using linked list in c 2b 2b