In this exercise, you will practice developing a data-type using the specificati
ID: 3644581 • Letter: I
Question
In this exercise, you will practice developing a data-type using the specification of another data-type.Specifically, in this exercise you need to develop an implementation of queue that only uses stacks as the underlying representation to store the elements of the queue. What that means is that you cannot use arrays or linke-list to store information pertaining to the queue. The only storage mechanism available to you is a stack and operations on the stack.
Note you can use one or more stack if needed.
Explanation / Answer
#include #include #include #include // Creating a NODE Structure struct node { int data; struct node *next; }; // Creating a class QUEUE class queue { struct node *frnt,*rear; public: queue() // constructure { frnt=rear=NULL; } void insert(); // to insert an element void del(); // to delete an element void show(); // to show the stack }; // Insertion void queue::insert() { int value; struct node *ptr; coutnext=NULL; if(frnt==NULL) frnt=ptr; else rear->next=ptr; rear=ptr; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.