In a priority queue, insertion and deletion can be done at

2023

In a priority queue, insertion and deletion can be done at

  1. A.

    front

  2. B.

    back

  3. C.

    middle

  4. D.

    any position

Attempted by 371 students.

Show answer & explanation

Correct answer: D

Concept

A priority queue is an abstract data type in which every element is associated with a priority value, and the order of processing is determined by that priority — not by the order of arrival. This is the defining property that separates it from an ordinary FIFO queue.

Application

  • Insertion: a new element must be placed so that the priority ordering is preserved, so it may go anywhere in the structure depending on its priority value — not fixed to one end.

  • Deletion: the element removed is always the one with the highest priority, and that element may reside anywhere in the structure, not only at a fixed end.

Contrast

  • front: only the first arrival is processed there in a FIFO queue — priority queues are not bound to the first arrival.

  • back: a FIFO queue inserts strictly at the rear — priority queues do not insert by arrival order.

  • middle: this fixes a single location, but priority queues are governed by priority value, not by any fixed slot.

Result

Because both operations are governed by priority value rather than a fixed end, insertion and deletion can take place at any position.

Explore the full course: Isro