0

You are required to implement a stack using an array. If the array is full, the bottom item is dropped from the stack.

how to do that

26th Sep 2019, 7:23 AM
Simran Mengi
Simran Mengi - avatar
1 ответ
+ 3
I'd write a container class that contains the array as private member and keeps track of the amount of elements that were inserted. Also this class should offer methods like push, pop and top to add, delete and access elements. If the array is full inserting a new element is very expensive because you need to shift the whole array... Btw. using an array isn't a good idea and the STL has already a stack container that's usually implemented very well. http://www.cplusplus.com/reference/stack/stack/
26th Sep 2019, 7:28 AM
Aaron Eberhardt
Aaron Eberhardt - avatar