Question: Using C, make a stack [ push() and pop()] of ints. At first, the stack should be able to hold 5 items. If you try

 Using C, make a stack [ push() and pop()] of ints.

Using C, make a stack [ push() and pop()] of ints. At first, the stack should be able to hold 5 items. If you try to push() onto a full stack, you should allocate a new block of memory for the stack then move over the items from the old stack, reassign the pointers, and then deallocate the old stack. You should try doubling the stack when you reach the limit. Don't allocate unnecessary amounts of memory, so if you had allocated 10 spaces and you only used 2, you should reallocate the stack size to 5. When reallocating, keep track by printing 'increasing/decreasing size from a to b

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!