logo Practice-It logo

BJP4 Self-Check 14.16: stackQueueMystery1

Language/Type: Java Collections mystery Stacks and Queues
Author: Marty Stepp (on 2016/09/08)

Write the output produced when the following method is passed each of the following stacks:

public static void mystery1(Stack s) {
    Queue<Integer> q = new LinkedList<Integer>();
    while (!s.isEmpty()) {
        int n = s.pop();
    while (!q.isEmpty()) {
[2, 6, 1]
[42, -3, 4, 15, 9]
[30, 20, 10, 60, 50, 40]

You must log in before you can solve this problem.

Log In

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.