Write a method called reorder that accepts a queue of integers as a parameter and that puts

Question:

Write a method called reorder that accepts a queue of integers as a parameter and that puts the integers into sorted (nondecreasing) order, assuming that the queue is already sorted by absolute value. For example, if the queue stores [1, 2, −2, 4, −5, 8, −8, 12, −15], notice that the values appear in sorted order if you ignore the sign of the numbers. Your method should reorder the values so that the queue stores [−15, −8, −5, −2, 1, 2, 4, 8, 12]. Use one stack 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: