Question: Create a C++ project and add the two files to it. Take a look at the stack implementation. 1. Write an arithmetic expression that will

Create a C++ project and add the two files to it.

Take a look at the stack implementation.

1. Write an arithmetic expression that will compute the number of elements in a stack given the value of top.

2. Does this expression give the correct answer for an empty stack? Explain.

3. What is the index of the top element of the stack.

4. What is the index of the bottom element of the stack?

5. Write a C++ expression that gives the value stored at the top of the stack.

6. Write a C++ expression that gives the value stored at the bottom of the stack.

Write a stack member function called elements that returns the number of elements in a stack (the stack should not be changed):

int elements ();

Write a stack member function called print_ends that prints the top element in the stack and then the bottom element in the stack with a space between them. It should not print a label, just the values from the stack.

void print_ends ();

Write a stack member function called change_bottom that sets the element at the bottom of the stack to its parameter:

void change_bottom (char new_item);

Make the following changes to the application file (there are comments to help instruct you where to place each item):

Declare a stack called stacky.

the characters F, L, O, W, E, and R on the stack.

Call your print_ends function to print the stack.

Change the bottom of the stack to P using change_bottom

the stack.

Call your print_ends function to print the stack

Print the number of elements in the stack (using the elements function to find the number of elements). Plug the call into the already present cout.

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!