logo CodeStepByStep logo


Language/Type: C++ collections Stack Queue

Write the output produced by the following function when passed each of the following queues and ints. Note: A stack displays/prints in {bottom ... top} order, and a queue displays in {front ... back} order.

void collectionMystery9(Queue<int>& queue, int p) {
    Stack<int> stack;
    int count = 0;
    int size = queue.size();
    for (int i = 0; i < size; i++) {
        int element = queue.dequeue();
        if (element < p) {
        } else {
    while (!stack.isEmpty()) {
    cout << queue << endl;
{1, 2, 3, 4, 5}, p=4
{67, 29, 115, 84, 33, 71, 90}, p=50

You must log in before you can solve this problem.

Log In

Need help?

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

Is there a problem? Contact a site administrator.

©, all rights reserved.