Exit Slides

Heap-based Priority Queue

overview

Summary

A heap_based_priority_queue stores items with priorities and returns the highest or lowest priority first. It is usually backed by a binary_heap, a complete binary tree in an array. Supported operations: insert, peek, and extract. A min_heap returns the smallest key; a max_heap returns the largest. Time costs: insert O(log n), extract O(log n), peek O(1). Heap order is maintained by heapify_up and heapify_down after updates.
← Prev Topic Slide 1 / 1 Next Topic: Tree →