Create a Stack using a 2D array in C++ I am trying to create a stack that resemb
ID: 3563713 • Letter: C
Question
Create a Stack using a 2D array in C++
I am trying to create a stack that resembles the effect of a linked list with 5 functions. I was wondering if someone could show how to construct a 2D array that has the maximum space of 25
Please add lots of comments.
Then create an empty stack (with capacity=25) and then start push 10 values (1,2,3,4,5,6,7,8,9,10) by Push( ) consecutively. After that, you will have 10 elements in your STACK. Run Display ( ) to print out the STACK. Then perform 3 times of Push( ) of value (20,30,40) on valid positions, run Display( ) to print out the list every time you insert a new element. Then perform 3 times of Top() and Pop( ), again, run Display( ) to print our the list every time you delete an element.
To visualize the requirement, the code should looks like:
Push(1)
Push(2)
Push(3)
Push(4)
Push(5)
Push(6)
Push(7)
Push(8)
Push(9)
Push(10)
Display()
Push(20)
Display()
Push(30)
Display()
Push(40)
Display()
Top()
Pop()
Display()
Top()
Pop()
Display()
Top()
Pop()
Display()