logo CodeStepByStep logo


Language/Type: C++ Stack Queue collections
Related Links:
Author: Marty Stepp (on 2016/06/29)

Write a function 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.

Type your C++ solution code here:

This is a function problem. Write a C++ function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.