{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Section7Problems 2

# Section7Problems 2 - 4 tists takes as paramet,ers two...

This preview shows pages 1–2. Sign up to view the full content.

4. Write a method equals that takes as paramet,ers two stacks containing tists\ of integers and that 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 metho. is to examine the two stacks but must return them to their original state before terminating. You are to use one stack as auxiliary storage to solve this problem. Methc eguals should take two parameters: the two Stacks to compare. 5. Write a method coJ-lapse that takes a Stack of integers as a parameter and that collapses it by replacing each successive pair of integers with the sur of the pair. For example, suppose a stack stores this sequence of va.Lues: bottom 17,2,8,9,4,13,7, Lr 9r 10l top Assume that, stack values appear from bot,tom to top. In other words, 7 is or the bottom, with 2 on top of it, with 8 on top of it, and so ofrr with 10 at the top of the stack.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

Section7Problems 2 - 4 tists takes as paramet,ers two...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online