Skip to main contentSkip to solution

Assume the queue is initially empty. What will be the result of the queue after performing the following operations in the given sequence?

enqueue(18)

enqueue(17)

enqueue(20)

dequeue()

enqueue(24)

dequeue()

Solution

✅ Correct Option: 1

A queue is FIFO (first in, first out), so dequeue always removes the element at the front.

OperationQueue (front to rear)
enqueue(18)18
enqueue(17)18 17
enqueue(20)18 17 20
dequeue()17 20
enqueue(24)17 20 24
dequeue()20 24

Option 2: this is the result if the structure were a stack (LIFO), where each dequeue would remove the most recent element (20, then 24).

Keyboard Shortcuts

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