Skip to main contentSkip to solution

What will be the status of the FRONT and REAR of queue after performing the following operations?

enqueue(27)

enqueue(24)

enqueue(47)

dequeue()

enqueue(37)

dequeue()

enqueue(12)

dequeue()

dequeue()

Solution

✅ Correct Option: 3

A queue is FIFO: enqueue adds at the REAR and dequeue removes from the FRONT.

OperationQueue (FRONT to REAR)
enqueue(27)27
enqueue(24)27, 24
enqueue(47)27, 24, 47
dequeue()24, 47
enqueue(37)24, 47, 37
dequeue()47, 37
enqueue(12)47, 37, 12
dequeue()37, 12
dequeue()12

Only 12 is left, so it is both FRONT and REAR.


Option 1: this is the queue after the third dequeue, before the last dequeue.

Option 2: this is the queue after the second dequeue, before enqueue(12).

Keyboard Shortcuts

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