SlideShare a Scribd company logo
1 of 3
Download to read offline
A deque (pronounced deck) is an ordered set of items from which items may be deleted at either
end and into which items may be inserted at either end. Call the two ends left and right. This is
an access-restricted structure since no insertions or deletions can happen other than at the ends.
Implement a deque as a doubly-linked circular list with a header. Write InsertRight and
DeleteLeft.
Solution
code:
#include
using namespace std;
class Node
{
public:
int data;
Node* next;
Node* prev;
};
class Deque
{
private:
Node* front;
Node* rear;
int count;
public:
Deque()
{
front = NULL;
rear = NULL;
count = 0;
}
bool isEmpty()
{
if(count == 0)
return true;
else
return false;
}
int DeleteLeft()
{
if ( isEmpty() ) {
cout<<"deque is empty... can't delete'";
return -1;
}
int ret = front->data;
Node* tmp = front;
if ( front->next != NULL )
{
front = front->next;
front->prev = NULL;
}
else
{
front = NULL;
}
count--;
delete tmp;
return ret;
}
void InsertRight(int element)
{
Node* tmp = new Node();
tmp->data = element;
tmp->next = NULL;
tmp->prev = NULL;
if ( isEmpty() ) {
front = rear = tmp;
}
else {
rear->next = tmp;
tmp->prev = rear;
rear = tmp;
}
count++;
}
};
int main()
{
Deque q;
if ( q.isEmpty() )
{
cout << "Deque is empty" << endl;
}
q.InsertRight(100);
q.InsertRight(200);
q.InsertRight(300);
Deque q1;
if ( q1.isEmpty() )
{
cout << "Deque is empty" << endl;
}
q1.InsertRight(100);
q1.InsertRight(200);
q1.InsertRight(300);
cout << q1.DeleteLeft() << endl;
cout << q1.DeleteLeft() << endl;
cout << q1.DeleteLeft() << endl;
}

More Related Content

Similar to A deque (pronounced deck) is an ordered set of items from which item.pdf

Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfconnellalykshamesb60
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfaromalcom
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfaathiauto
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfkostikjaylonshaewe47
 
Lecture11 standard template-library
Lecture11 standard template-libraryLecture11 standard template-library
Lecture11 standard template-libraryHariz Mustafa
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
How to build a Linked List that can insert any type of data. For exa.pdf
How to build a Linked List that can insert any type of data. For exa.pdfHow to build a Linked List that can insert any type of data. For exa.pdf
How to build a Linked List that can insert any type of data. For exa.pdfarpittradersjdr
 
Below is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docxBelow is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docxgilliandunce53776
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxtienlivick
 
Data structure doubly linked list programs
Data structure doubly linked list programsData structure doubly linked list programs
Data structure doubly linked list programsiCreateWorld
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 

Similar to A deque (pronounced deck) is an ordered set of items from which item.pdf (20)

linkedlist.pptx
linkedlist.pptxlinkedlist.pptx
linkedlist.pptx
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdf
 
linkedLists.ppt
linkedLists.pptlinkedLists.ppt
linkedLists.ppt
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdf
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
Lecture11 standard template-library
Lecture11 standard template-libraryLecture11 standard template-library
Lecture11 standard template-library
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
Op ps
Op psOp ps
Op ps
 
How to build a Linked List that can insert any type of data. For exa.pdf
How to build a Linked List that can insert any type of data. For exa.pdfHow to build a Linked List that can insert any type of data. For exa.pdf
How to build a Linked List that can insert any type of data. For exa.pdf
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Below is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docxBelow is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docx
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
Data structure doubly linked list programs
Data structure doubly linked list programsData structure doubly linked list programs
Data structure doubly linked list programs
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 

More from hardjasonoco14599

[Quantum Mechanics] In my class we are talking about the quantum har.pdf
[Quantum Mechanics] In my class we are talking about the quantum har.pdf[Quantum Mechanics] In my class we are talking about the quantum har.pdf
[Quantum Mechanics] In my class we are talking about the quantum har.pdfhardjasonoco14599
 
Write a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdfWrite a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdfhardjasonoco14599
 
what is tax preferenceSolutionTax preferences are measures of .pdf
what is tax preferenceSolutionTax preferences are measures of .pdfwhat is tax preferenceSolutionTax preferences are measures of .pdf
what is tax preferenceSolutionTax preferences are measures of .pdfhardjasonoco14599
 
Which of the following is true regarding homologous structuresA. .pdf
Which of the following is true regarding homologous structuresA. .pdfWhich of the following is true regarding homologous structuresA. .pdf
Which of the following is true regarding homologous structuresA. .pdfhardjasonoco14599
 
Why is it reasonable to assume that Venus, Earth, and Mars started w.pdf
Why is it reasonable to assume that Venus, Earth, and Mars started w.pdfWhy is it reasonable to assume that Venus, Earth, and Mars started w.pdf
Why is it reasonable to assume that Venus, Earth, and Mars started w.pdfhardjasonoco14599
 
Which of the following is NOT a complication in development of an HIV.pdf
Which of the following is NOT a complication in development of an HIV.pdfWhich of the following is NOT a complication in development of an HIV.pdf
Which of the following is NOT a complication in development of an HIV.pdfhardjasonoco14599
 
Write a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfWrite a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfhardjasonoco14599
 
Which of the following groups is responsible for the actual developm.pdf
Which of the following groups is responsible for the actual developm.pdfWhich of the following groups is responsible for the actual developm.pdf
Which of the following groups is responsible for the actual developm.pdfhardjasonoco14599
 
Whats the role of the gastric caeca in a grasshopperSolutionGr.pdf
Whats the role of the gastric caeca in a grasshopperSolutionGr.pdfWhats the role of the gastric caeca in a grasshopperSolutionGr.pdf
Whats the role of the gastric caeca in a grasshopperSolutionGr.pdfhardjasonoco14599
 
what does it takes to be a living organ What does it take to be a l.pdf
what does it takes to be a living organ What does it take to be a l.pdfwhat does it takes to be a living organ What does it take to be a l.pdf
what does it takes to be a living organ What does it take to be a l.pdfhardjasonoco14599
 
ve targets. ball and sodket hinge joint condyloid joint saddle jo.pdf
ve targets. ball and sodket hinge joint condyloid joint saddle jo.pdfve targets. ball and sodket hinge joint condyloid joint saddle jo.pdf
ve targets. ball and sodket hinge joint condyloid joint saddle jo.pdfhardjasonoco14599
 
This one is for you - assume that this pedigree shows the inheritance.pdf
This one is for you - assume that this pedigree shows the inheritance.pdfThis one is for you - assume that this pedigree shows the inheritance.pdf
This one is for you - assume that this pedigree shows the inheritance.pdfhardjasonoco14599
 
There are 7 people in the elevator in a 10-story building. They are .pdf
There are 7 people in the elevator in a 10-story building. They are .pdfThere are 7 people in the elevator in a 10-story building. They are .pdf
There are 7 people in the elevator in a 10-story building. They are .pdfhardjasonoco14599
 
safety Construction Safety-Quiz 1 According to OSHA, what must man.pdf
safety Construction Safety-Quiz 1 According to OSHA, what must man.pdfsafety Construction Safety-Quiz 1 According to OSHA, what must man.pdf
safety Construction Safety-Quiz 1 According to OSHA, what must man.pdfhardjasonoco14599
 
Question 1 A ____________ is an intelligent device that controls the.pdf
Question 1 A ____________ is an intelligent device that controls the.pdfQuestion 1 A ____________ is an intelligent device that controls the.pdf
Question 1 A ____________ is an intelligent device that controls the.pdfhardjasonoco14599
 
I finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdfI finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdfhardjasonoco14599
 
In sliding window protocol the left wall of the sender sliding winod.pdf
In sliding window protocol the left wall of the sender sliding winod.pdfIn sliding window protocol the left wall of the sender sliding winod.pdf
In sliding window protocol the left wall of the sender sliding winod.pdfhardjasonoco14599
 
In mice, the black allele (B) is dominant to the recessive white all.pdf
In mice, the black allele (B) is dominant to the recessive white all.pdfIn mice, the black allele (B) is dominant to the recessive white all.pdf
In mice, the black allele (B) is dominant to the recessive white all.pdfhardjasonoco14599
 
How will the rate of diffusion of an interstitial i Impurity atom Inc.pdf
How will the rate of diffusion of an interstitial i Impurity atom Inc.pdfHow will the rate of diffusion of an interstitial i Impurity atom Inc.pdf
How will the rate of diffusion of an interstitial i Impurity atom Inc.pdfhardjasonoco14599
 
Let R be an integral domain. Prove 1R and -1R are the only units of .pdf
Let R be an integral domain. Prove 1R and -1R are the only units of .pdfLet R be an integral domain. Prove 1R and -1R are the only units of .pdf
Let R be an integral domain. Prove 1R and -1R are the only units of .pdfhardjasonoco14599
 

More from hardjasonoco14599 (20)

[Quantum Mechanics] In my class we are talking about the quantum har.pdf
[Quantum Mechanics] In my class we are talking about the quantum har.pdf[Quantum Mechanics] In my class we are talking about the quantum har.pdf
[Quantum Mechanics] In my class we are talking about the quantum har.pdf
 
Write a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdfWrite a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdf
 
what is tax preferenceSolutionTax preferences are measures of .pdf
what is tax preferenceSolutionTax preferences are measures of .pdfwhat is tax preferenceSolutionTax preferences are measures of .pdf
what is tax preferenceSolutionTax preferences are measures of .pdf
 
Which of the following is true regarding homologous structuresA. .pdf
Which of the following is true regarding homologous structuresA. .pdfWhich of the following is true regarding homologous structuresA. .pdf
Which of the following is true regarding homologous structuresA. .pdf
 
Why is it reasonable to assume that Venus, Earth, and Mars started w.pdf
Why is it reasonable to assume that Venus, Earth, and Mars started w.pdfWhy is it reasonable to assume that Venus, Earth, and Mars started w.pdf
Why is it reasonable to assume that Venus, Earth, and Mars started w.pdf
 
Which of the following is NOT a complication in development of an HIV.pdf
Which of the following is NOT a complication in development of an HIV.pdfWhich of the following is NOT a complication in development of an HIV.pdf
Which of the following is NOT a complication in development of an HIV.pdf
 
Write a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfWrite a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdf
 
Which of the following groups is responsible for the actual developm.pdf
Which of the following groups is responsible for the actual developm.pdfWhich of the following groups is responsible for the actual developm.pdf
Which of the following groups is responsible for the actual developm.pdf
 
Whats the role of the gastric caeca in a grasshopperSolutionGr.pdf
Whats the role of the gastric caeca in a grasshopperSolutionGr.pdfWhats the role of the gastric caeca in a grasshopperSolutionGr.pdf
Whats the role of the gastric caeca in a grasshopperSolutionGr.pdf
 
what does it takes to be a living organ What does it take to be a l.pdf
what does it takes to be a living organ What does it take to be a l.pdfwhat does it takes to be a living organ What does it take to be a l.pdf
what does it takes to be a living organ What does it take to be a l.pdf
 
ve targets. ball and sodket hinge joint condyloid joint saddle jo.pdf
ve targets. ball and sodket hinge joint condyloid joint saddle jo.pdfve targets. ball and sodket hinge joint condyloid joint saddle jo.pdf
ve targets. ball and sodket hinge joint condyloid joint saddle jo.pdf
 
This one is for you - assume that this pedigree shows the inheritance.pdf
This one is for you - assume that this pedigree shows the inheritance.pdfThis one is for you - assume that this pedigree shows the inheritance.pdf
This one is for you - assume that this pedigree shows the inheritance.pdf
 
There are 7 people in the elevator in a 10-story building. They are .pdf
There are 7 people in the elevator in a 10-story building. They are .pdfThere are 7 people in the elevator in a 10-story building. They are .pdf
There are 7 people in the elevator in a 10-story building. They are .pdf
 
safety Construction Safety-Quiz 1 According to OSHA, what must man.pdf
safety Construction Safety-Quiz 1 According to OSHA, what must man.pdfsafety Construction Safety-Quiz 1 According to OSHA, what must man.pdf
safety Construction Safety-Quiz 1 According to OSHA, what must man.pdf
 
Question 1 A ____________ is an intelligent device that controls the.pdf
Question 1 A ____________ is an intelligent device that controls the.pdfQuestion 1 A ____________ is an intelligent device that controls the.pdf
Question 1 A ____________ is an intelligent device that controls the.pdf
 
I finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdfI finished most of the program, but having trouble with some key fea.pdf
I finished most of the program, but having trouble with some key fea.pdf
 
In sliding window protocol the left wall of the sender sliding winod.pdf
In sliding window protocol the left wall of the sender sliding winod.pdfIn sliding window protocol the left wall of the sender sliding winod.pdf
In sliding window protocol the left wall of the sender sliding winod.pdf
 
In mice, the black allele (B) is dominant to the recessive white all.pdf
In mice, the black allele (B) is dominant to the recessive white all.pdfIn mice, the black allele (B) is dominant to the recessive white all.pdf
In mice, the black allele (B) is dominant to the recessive white all.pdf
 
How will the rate of diffusion of an interstitial i Impurity atom Inc.pdf
How will the rate of diffusion of an interstitial i Impurity atom Inc.pdfHow will the rate of diffusion of an interstitial i Impurity atom Inc.pdf
How will the rate of diffusion of an interstitial i Impurity atom Inc.pdf
 
Let R be an integral domain. Prove 1R and -1R are the only units of .pdf
Let R be an integral domain. Prove 1R and -1R are the only units of .pdfLet R be an integral domain. Prove 1R and -1R are the only units of .pdf
Let R be an integral domain. Prove 1R and -1R are the only units of .pdf
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

A deque (pronounced deck) is an ordered set of items from which item.pdf

  • 1. A deque (pronounced deck) is an ordered set of items from which items may be deleted at either end and into which items may be inserted at either end. Call the two ends left and right. This is an access-restricted structure since no insertions or deletions can happen other than at the ends. Implement a deque as a doubly-linked circular list with a header. Write InsertRight and DeleteLeft. Solution code: #include using namespace std; class Node { public: int data; Node* next; Node* prev; }; class Deque { private: Node* front; Node* rear; int count; public: Deque() { front = NULL; rear = NULL; count = 0; } bool isEmpty()
  • 2. { if(count == 0) return true; else return false; } int DeleteLeft() { if ( isEmpty() ) { cout<<"deque is empty... can't delete'"; return -1; } int ret = front->data; Node* tmp = front; if ( front->next != NULL ) { front = front->next; front->prev = NULL; } else { front = NULL; } count--; delete tmp; return ret; } void InsertRight(int element) { Node* tmp = new Node(); tmp->data = element; tmp->next = NULL; tmp->prev = NULL; if ( isEmpty() ) { front = rear = tmp; }
  • 3. else { rear->next = tmp; tmp->prev = rear; rear = tmp; } count++; } }; int main() { Deque q; if ( q.isEmpty() ) { cout << "Deque is empty" << endl; } q.InsertRight(100); q.InsertRight(200); q.InsertRight(300); Deque q1; if ( q1.isEmpty() ) { cout << "Deque is empty" << endl; } q1.InsertRight(100); q1.InsertRight(200); q1.InsertRight(300); cout << q1.DeleteLeft() << endl; cout << q1.DeleteLeft() << endl; cout << q1.DeleteLeft() << endl; }