Skip to main contentSkip to solution

Consider an initially empty queue. Which of the following elements will be present in the queue after the execution of the following operations?

enqueue(a)

enqueue(b)

enqueue(c)

dequeue()

enqueue(d)

dequeue()

dequeue()

A. a

B. b

C. c

D. d

Solution

✅ Correct Option: 1

A queue is FIFO (first in, first out), so each dequeue removes the oldest element.

OperationQueue (front to rear)
enqueue(a)a
enqueue(b)a, b
enqueue(c)a, b, c
dequeue() removes ab, c
enqueue(d)b, c, d
dequeue() removes bc, d
dequeue() removes cd

Only d remains.


Option 2 (A only): a is the first element enqueued, so it is the first one removed. It is not the one left.

Option 4 (B and C only): this would be the result if d were never enqueued and only one dequeue ran. Here three dequeues remove a, b and c.

Keyboard Shortcuts

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