Question: 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
 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

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

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 Databases Questions!