Write a method called mirrorHalves that accepts a queue of integers as a parameter and replaces each

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: