Skip to main contentSkip to solution

The elements A, B, C, D, E are to be entered in an empty queue starting from A. The following operations are performed:

Enqueue(), Enqueue(), Enqueue(), Dequeue(), Enqueue(), Dequeue()

What will be the status of the queue after the above operation?

Solution

✅ Correct Option: 1

A queue is first in, first out (FIFO): Enqueue adds at the rear and Dequeue removes from the front. The elements are taken in the order A, B, C, D, E.

OperationQueue (front to rear)
Enqueue()A
Enqueue()A, B
Enqueue()A, B, C
Dequeue()B, C
Enqueue()B, C, D
Dequeue()C, D

Options 2 and 4: there are only four Enqueue operations, so E is never entered.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question