Question: For this machine problem you are to write a stack class and a queue class. Both are to be implementd by a circular doubly linked

For this machine problem you are to write a stack class and a queue class.
Both are to be implementd by a circular doubly linked list.
In addition, your program should be written by suppling he missing class
methods. No changes to the given code are allowed. In each case the test
data is built into the program.
Here is the stack.
#include
#include
using namespace std;
class stack {
private:
struct _dlink{
char value;
_dlink * prev, * next;
}_base;
public:
stack();
bool is_empty();
char pop();
void push(char);
char top();
};
/* missing class methods go here. */
int main(){
stack stk;
stk.push(a);
stk.push(b);
1
stk.push(c);
stk.push(d);
while(!stk.is_empty()){
cout << stk.top()<<
;
cout << stk.pop()<<
;
cout <<"
---------------------
";
}
}
And here is the queue.
#include
#include
using namespace std;
class queue{
private:
struct _dlink{
char value;
_dlink * prev, * next;
}_base;
public:
queue();
bool is_empty();
char dequeue();
void enqueue(char);
};
/* missing class methods go here. */
int main(){
queue que;
2
que.enqueue(a);
que.enqueue(b);
que.enqueue(c);
que.enqueue(d);
while(!que.is_empty()){
cout << que.dequeue()<<
;
cout <<"
---------------------
";
}
}
can u do write stack class and a queue class 2 different code. so one code in stack class and one code in queue class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!