logo CodeStepByStep logo


Language/Type: C# Stack Queue collections

Write a method named Reorder that accepts as a parameter a queue of integers that are already sorted by absolute value, and modifies it so that the integers are sorted normally. For example, if a queue variable named q stores the following elements:

front {1, -2, 4, 5, -7, -9, -12, 28, -34} back

Then the call of Reorder(q); should modify it to store the following values:

front {-34, -12, -9, -7, -2, 1, 4, 5, 28} back

Constraints: You may use a single stack as auxiliary storage.

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.