Question: 1. Suppose a stack contains the following strings, starting at the top: red, blue, green, and yellow. Draw a sketch of the stack containing these

1. Suppose a stack contains the following strings, starting at the top: "red", "blue", "green", and "yellow". Draw a sketch of the stack containing these values as implemented using 1) a singly linked list, and 2) a fixed-capacity vector. Remember to include all the structures' data members.

2. Write the main() function of a program that

a.Creates an empty stack of integers. You may use either the C++ built-in stack data structure (C++ Language Library); or the linked linked stack or fixed array stack in our github repository.

b.Repeatedly ask the user to input an integer x. If x is positive, push x onto the stack. If x is zero, print and pop one element from the stack. If x is negative, exit the input loop.

c.Print and pop all remaining elements off the stack, if any.

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!