60 363
Assignments Done
98%
Successfully Done
In April 2018

Answer to Question #8323 in C++ for eugine

Question #8323
algorithm to copy contents of stack using a while loop
Expert's answer
Assuming that you only have push, pop, peek and IsEmpty operations you need two loops, and an intermediate stack:
In the first loop, you pop each item off the stack, and push it onto the temporary stack.
In the second loop, you pop each item off the temporary stack and push it onto both the original stack and the output stack.
&
If you can traverse the start from the bottom, then it isn't a stack copy operation, it's just a memory copy job.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions