Question: Write a method called mirrorHalves that accepts a queue of integers as a parameter and replaces each half of that queue with itself plus a
Write a method called mirrorHalves that accepts a queue of integers as a parameter and replaces each half of that queue with itself plus a mirrored version of itself (the same elements in the opposite order). For example, if the queue stores [10, 50, 19, 54, 30, 67], your method should change it to store [10, 50, 19, 19, 50, 10, 54, 30, 67, 67, 30, 54] . If your method is passed an empty queue, the result should be an empty queue. If your method is passed a queue whose size is not even, throw an IllegalArgumentException . Use one stack or one queue (but not both) as auxiliary storage.
Step by Step Solution
3.38 Rating (160 Votes )
There are 3 Steps involved in it
public static void mirrorHalves Queue q if q null qs... View full answer
Get step-by-step solutions from verified subject matter experts
