Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Answer b-e 4. Write a stack class using an array (from the heap to implement What is a stack? We saw the run-time stack in
Answer b-e
4. Write a stack class using an array (from the heap to implement What is a "stack"? We saw the run-time stack in class. It is a data structure that allows us to push" an element to the "top", to from the "top". In fact, for the non-recursive towers problem, we used a vector as a stack. (50 points total) class stackt private int top; ll top is the index into the array for the current top int p; p is a pointer into the heap where the stack is actually IMocated. Just like for the SA class. int size; ll current size of the array allocated for the stack public: stack0; ll a stack to hold 100 elements stack(int n); ll a stack to hold n elements -stack0; bool fullo/l returns true if the stack is empty, false otherwise bool empty0; ll returns true if the stack is empty, false otherwise void push( int i); ll push new element to the top of the stack int pop0; ll return and remove the "top" element of the stack stack & operator cons stack& r); llassign one stack to another We should be able to do things like this: int mai 0f stack s(10), s push(1); s push(2); s push(3); for (i 0; i for (i 0; i 3: i++) cout Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started