Loading...
Searching...
No Matches
queue_using_linked_list.cpp
1#include <iostream> 2using namespacestd;
3 4struct node{
5 intval;
6 node*next;
7};
8 9node*front, *rear;
10 11voidEnque(
intx) {
12 if(rear == NULL) {
13 node*n =
new node;
14n->val = x;
15n->next = NULL;
16rear = n;
17front = n;
18}
19 20 else{
21 node*n =
new node;
22n->val = x;
23n->next = NULL;
24rear->next = n;
25rear = n;
26}
27}
28 29voidDeque() {
30 if(rear == NULL && front == NULL) {
31cout <<
"\nUnderflow";
32}
else{
33 node*t = front;
34cout <<
"\n"<< t->val <<
" deleted";
35front = front->next;
36 deletet;
37 if(front == NULL)
38rear = NULL;
39}
40}
41 42voidshow() {
43 node*t = front;
44 while(t != NULL) {
45cout << t->val <<
"\t";
46t = t->next;
47}
48}
49 50int main() {
51 intch, x;
52 do{
53cout <<
"\n1. Enque";
54cout <<
"\n2. Deque";
55cout <<
"\n3. Print";
56cout <<
"\nEnter Your Choice : ";
57cin >> ch;
58 if(ch == 1) {
59cout <<
"\nInsert : ";
60cin >> x;
61Enque(x);
62}
else if(ch == 2) {
63Deque();
64}
else if(ch == 3) {
65show();
66}
67}
while(ch != 0);
68 69 return0;
70}
nodestruct node { int data; int height; struct node *left; struct node *right;} node
for std::queue
Definition avltree.cpp:13 mainint main()
Main function.
Definition generate_parentheses.cpp:110 node Definition binary_search_tree.cpp:11RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4