Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume the class ArrayStack and the class ArrayQueue have been implemented using the implementations in zybooks, module presentations and in sample code. Assume also that

Assume the class ArrayStack and the class ArrayQueue have been implemented using the implementations in zybooks, module presentations and in sample code. Assume also that the code compiles and executes without errors. Given the following code fragment:
ArrayStack myStack;
ArrayQueue myQueue;
int i =4;
int j =3;
int k =2;
int n =1;
myStack.push (j);
myQueue.enqueue (j);
myStack.push (k);
myQueue.enqueue (k);
myStack.push (i);
myQueue.enqueue (i);
j = myStack.peek ();
myStack.pop ();
j = myQueue.peekFront ();
myQueue.dequeue ();
myStack.push (n);
myQueue.enqueue (n);
n = myQueue.peekFront ();
myQueue.dequeue ();
n = myStack.peek ();
myStack.pop ();
myStack.push (j);
myQueue.enqueue (j);
myStack.push (n);
myQueue.enqueue (n);
j++;
myStack.push (j);
myQueue.enqueue (j);
n++;
myStack.push (n);
myQueue.enqueue (n);
//Type the exact output produced by the following code fragment in the box below it.
while (!myStack.isEmpty())
{
i = myStack.peek ();
myStack.pop ();
cout << i <<"";
}
cout << endl;Assume the class ArrayStack and the class ArrayQueue have been implemented using the implementations in zybooks, module presentations and in sample code. Assume also that the code compiles and executes without errors. Given the following code fragment:
ArrayStack myStack;
ArrayQueue myQueue;
int i =4;
int j =3;
int k =2;
int n =1;
myStack.push (j);
myQueue.enqueue (j);
myStack.push (k);
myQueue.enqueue (k);
myStack.push (i);
myQueue.enqueue (i);
j = myStack.peek ();
myStack.pop ();
j = myQueue.peekFront ();
myQueue.dequeue ();
myStack.push (n);
myQueue.enqueue (n);
n = myQueue.peekFront ();
myQueue.dequeue ();
n = myStack.peek ();
myStack.pop ();
myStack.push (j);
myQueue.enqueue (j);
myStack.push (n);
myQueue.enqueue (n);
j++;
myStack.push (j);
myQueue.enqueue (j);
n++;
myStack.push (n);
myQueue.enqueue (n);
//Type the exact output produced by the following code fragment in the box below it.
while (!myStack.isEmpty())
{
i = myStack.peek ();
myStack.pop ();
cout << i <<"";
}
cout << endl;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

5. Explain how to install a performance management program.

Answered: 1 week ago