Question: Please rewrite the following code so that after the first doubling of the array, halve the size of the array if fewer than half of
Please rewrite the following code so that after the first doubling of the array, halve the size of the array if fewer than half of the arrays locations are occupied by current stack entries.
in C++
Thank you
#include //main method int main() { //initialize an object of ADTStack ADTStack stack; //push and pop operations only for testing purpose stack.push(20); //pushed element 20 stack.push(30); //pushed element 20 stack.push(40); //pushed element 20 stack.push(50); //pushed element 20 stack.push(60); //pushed element 20 stack.push(70); //pushed element 20 stack.push(80); //pushed element 20 stack.display(); //display the contents of stack stack.pop(); //pop one element stack.display(); //now again display the contents of stack return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
