42.4k views
5 votes
ArrayQueue q1 = new ArrayQueue (5);

q1. enqueue ("100");
q1. enqueue ("240");
q1. enqueue ("365");
q1. dequeue ();
q1. enqueue ("653");
q1. dequeue ();
q1.enqueue("777");
q1.enqueue("520");
After executing the above program statements,
The object in the front of the queue q1 is ___________
The size of the queue q1 is _____________
The front value in the queue q1 is____________
The rear value in the queue q1 is ____________

User ZFTurbo
by
7.6k points

1 Answer

3 votes

Final answer:

After the sequence of enqueue and dequeue operations, the object at the front of the queue q1 is "365", the size of the queue is 4, the front value is "365", and the rear value is "520".

Step-by-step explanation:

When executing the given sequence of operations on an ArrayQueue object named q1, we process a sequence of enqueues and dequeues that modify the contents and state of the queue.

  • At first, "100", "240", and "365" are enqueued in that order.
  • The dequeue operation removes "100" from the front.
  • Enqueuing "653" adds it to the rear.
  • The next dequeue removes "240".
  • Finally, "777" and "520" are enqueued.

Considering these operations:

  • The object at the front would now be "365".
  • The size of the queue will be 4, because there are four elements left.
  • The front value, as mentioned, is "365".
  • The rear value is the last element queued, which is "520".

User Dick Chesterwood
by
9.1k points