Question #59458

Trace a Queue (called Q) through the following operations:

Queue Q = new Queue();

Q.enqueue(new Integer(4));

Q.enqueue(new Integer(3));

//a) What is the content of the queue at this point?

Integer Y = Q.dequeue();

Q.enqueue(new Integer(7));

Q.enqueue(new Integer(2));

Q.enqueue(new Integer(5));

Q.enqueue(new Integer(9));

//b) What is the content of the queue at this point?

Integer Y = Q.dequeue();

Q.enqueue(new Integer(3));

Q.enqueue(new Integer(9));

//c) What is the content of the queue at this point?

Expert's answer

a) 4, 3
b) 3, 7, 2, 5, 9
c) 7, 2, 5, 9, 3, 9
(all answers represent queue from front to back, from left to right)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS