Question: Write a method called mirror that accepts a stack of integers as a parameter and replaces the stack contents with itself plus a mirrored version
Write a method called mirror that accepts a stack of integers as a parameter and replaces the stack contents with itself plus a mirrored version of itself (the same elements in the opposite order). For example, if the stack stores [10, 53, 19, 24] , your method should change it to store [10, 53, 19, 24, 24, 19, 53, 10] . If passed an empty stack, your result should be an empty stack. Use one stack or one queue (but not both) as auxiliary storage to solve this problem.
Step by Step Solution
3.42 Rating (152 Votes )
There are 3 Steps involved in it
public static void mirror Stack s if s null throw new Illegal... View full answer
Get step-by-step solutions from verified subject matter experts
