Heap

Domain: Data Structures

🎯 Motivation

When you need quick access to the largest or smallest element, a heap keeps the extreme value at the top without full sorting.

📋 Concrete Example

A max-heap: parent always >= children. The largest value is at the root. heapq in Python implements a min-heap.

🔗 Analogy

A VIP club where the most important person always stands at the front of the line. When they leave, the next most important moves up.