Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The goal of this assignment is to reinforce the concept of stacks and their implementation. Specifically, the assignment is to implement additional functions to manipulate

image text in transcribed

The goal of this assignment is to reinforce the concept of stacks and their implementation. Specifically, the assignment is to implement additional functions to manipulate stack objects of different types. To keep the assignment uniform for all, we will use the STL template class stack. See slides for sample code on how to work with STL template class stack. Design and implement the following functions in a test program in file called test_stack.cpp: 1. Function topToButtom (...) takes a stack object of type integer and displays the stack content from the top of the stack to the bottom of the stack. That is, the top value is printed first; while the bottom value is printed last. This function does not change the stack content. 2. Function buttonToTop (--) takes a stack object of type double and displays the stack content from the bottom of the stack to the top of the stack. That is, the bottom value is printed first; while the top value is printed last. This function does not change the stack content. 3. Function flipStack (...) takes a stack object of type string and returns the same stack object with its content being flipped. That is, if the stack has values are Ed, Tom, Bob, Amy before calling this function, the stack would have the values Amy, Bob, Ed, Tom after the function is executed. 4. Function searchStack (...) takes 2 parameters: a stack object of type integer and an integer target value. It returns true if the target value is on the stack at any place; otherwise it returns false. This function does not change the stack content 5. Function chcekifPalindrome (n.) takes a stack object of type character and returns true if the stack content represents a palindrome (i.e., the stack content has the same order if read top to bottom or bottom to top). For example, a stack with values R, A, C, E, C, A, R is a palindrome; while a stack with values T, H, I, S, C, L, A, S, s is not a palindrome; Write your main function (main()) as part of file test_stack.cpp and test every function listed above. Make your outputs clean and meaningful, an follow this sample run to format your outputs: Testing function topToButtom: Stack content: 3 4 5 5 7 8 8 Function output: 3 4 5 5 7 8 8 Testing function buttomToTop: Stack content: 3.5 4.6 5.5 9.7 Function output: 9.7 5.5 4.6 3.5 Testing function flipStack: Stack content before: Ed Tom Stack content after: Amy Bob Bob Tom Amy Ed 1 15 25 Testing function searchStack: Stack content: 11 14 Target value: Function output: false 71 60 95 88

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

Students also viewed these Databases questions

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago

Question

=+Understand the fi eld of comparative IHRM.

Answered: 1 week ago