Skip to main contentSkip to solution

Show the status of queue after the following operations:

enqueue(34)

enqueue(54)

dequeue( )

enqueue(12)

enqueue(9)

enqueue(61)

dequeue( )

Solution

✅ Correct Option: 1

A queue is FIFO (First In, First Out): elements are added at the rear and removed from the front, so dequeue always removes the oldest element.

OperationQueue (front to rear)
enqueue(34)34
enqueue(54)34, 54
dequeue( )54
enqueue(12)54, 12
enqueue(9)54, 12, 9
enqueue(61)54, 12, 9, 61
dequeue( )12, 9, 61

Option 3: shows 12 removed as well, which would need a third dequeue.

Options 2 and 4: 61 was enqueued and never dequeued, so it must still be in the queue.

Keyboard Shortcuts

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