Skip to main contentSkip to solution

What will be the front of the QUEUE after following operations are performed on the elements of the list [4, 5, 12, 21, 14, 6, 8, 10, 18]?

enqueue

enqueue

dequeue

enqueue

enqueue

enqueue

dequeue

dequeue

Solution

✅ Correct Option: 1

A queue is FIFO (first in, first out). Each enqueue adds the next element of the list at the rear, and each dequeue removes the element at the front.

OperationQueue (front on the left)
enqueue4
enqueue4, 5
dequeue (removes 4)5
enqueue5, 12
enqueue5, 12, 21
enqueue5, 12, 21, 14
dequeue (removes 5)12, 21, 14
dequeue (removes 12)21, 14

The front element is 21.

Keyboard Shortcuts

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