Imagine you have a program where the digits 0 through 9 are pushed, in order, on
ID: 640726 • Letter: I
Question
- Imagine you have a program where the digits 0 through 9 are pushed, in order, onto a Stack. Each digit is popped off the Stack in turn and pushed onto a second Stack. Then they are all popped off the second Stack and printed on a single line with a space between each digit. What will the output of this program be?
- Write a method reverse that takes an ArrayList of Integers as an argument and returns a new ArrayList of Integers that is the reverse of the original list. For example, if the original list was [9, 7, 4, 6] the method should return [6, 4, 7, 9]. You method must use a Stack to perform this reverse operation.
Explanation / Answer
1)
again prints 0-9
2)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.