GK Question

technology medium mcq

Which data structure is best suited for implementing a priority queue?

  1. Array
  2. Linked List
  3. Heap
  4. Stack

Answer: Heap

Heap (specifically binary heap) efficiently implements priority queue with O(log n) insertion and extraction of highest/lowest priority element. Arrays/lists require O(n) search for priority element. Heaps maintain partial order: parent node has higher/lower priority than children. Used in scheduling, Dijkstra's algorithm, and event simulation.

Topic Programming Logic
Exam Relevance SSC JE, Banking IT, Railway