Question: Q2. [20 marks] Describe an algorithm sameStack that takes as parameters two stacks of integers and returns true if the two stacks are equal and
![Q2. [20 marks] Describe an algorithm sameStack that takes as parameters](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4ff1a757ee_12166f4ff19d6a9d.jpg)
Q2. [20 marks] Describe an algorithm sameStack that takes as parameters two stacks of integers and returns true if the two stacks are equal and that returns false otherwise. To be considered equal, the two stacks would have to store the same sequence of integer values in the same order. Your algorithm should examine the two stacks but for full points must return them to their original state before terminating. You may use one stack as auxiliary storage. Addendum for clarification added 26/2/21: You may use fundamental/standard stack methods pop, push, top, and size without writing extra pseudocode for the those methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
