subject

C++ Sometimes a program requires two stacks containing the same type of entries. two coexisting stacks If the two stacks are stored in separate arrays, then one stack might overflow while there was considerable unused space in the other. A neat way to avoid this problem is to put all the space in one array and let one stack grow from one end of the array and the other stack start at the other end and grow in the opposite direction, i. e.,toward the first stack. In this way, if one stack turns out to be large and the other small, then they will still both fit, and there will be no overflow until all the space is actually used. 1) Declare a new class Double_stack that includes (as private data members) the array and the two indices top_a and top_b, and write function implementations for the methods Double_stack( ), push_a( ), push_b(), pop_a( ), pop_b( ), top_a( ), top_b( ), empty_a( ), empty_b( ), and full( ) to handle the two stacks within one Double_stack. 2) Document your code with comments, and write the test program to test every member functions implemented in the class. 3) Write a summary report that includes your displayed test results.
const int maxstack = 20;//small value for testing
typedef int Stack_entry;
class Double_stack
{
public:
Double_stack( );
bool empty_a( )const;
bool empty_b( )const;
bool full( )const ;//Same method checks both stacks for fullness.
void pop_a( );
void pop_b( );
Stack_entry top_a( )const;
Stack_entry top_b( )const;
void push_a(const Stack_entry&item);
void push_b(const Stack_entry&item);
private:
int top_a;//index of top of stacka; −1 if empty
int top_b;//index of top of stackb; maxstack if empty
Stack_entry entry[maxstack];
};

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:30
My mom and i are moving and we don’t have wifi for the next week, i want to know if using a using a hotspot with unlimited data is better than using regular wifi. i’m considering cost, speed, and data sacrifices.
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
The salespeople at hyperactive media sales all use laptop computers so they can take data with them on the road. you are a salesperson for superduper lightspeed computers talking to hyperactive media sales about upgrading the laptops to windows 10. explain how network location awareness in windows 10 would make the laptops more secure.
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
1. for which of the following are you not required to signal beforehand? a. changing lanes b. speeding up c. stopping
Answers: 2
You know the right answer?
C++ Sometimes a program requires two stacks containing the same type of entries. two coexisting sta...
Questions