What is a heap?

Dijkstra Algorithm Questions



80 Short 62 Medium 80 Long Answer Questions Question Index

What is a heap?

A heap is a specialized tree-based data structure that satisfies the heap property. It is commonly used in the implementation of priority queues. In a heap, each node has a value associated with it, and the value of each node is either greater than or equal to (in a max heap) or less than or equal to (in a min heap) the values of its children. The root node of the heap represents the highest (or lowest) priority element. The heap property ensures efficient retrieval of the highest (or lowest) priority element, making it suitable for applications like Dijkstra's algorithm.