The two properties
A heap is a complete binary tree obeying one ordering rule at every node.
- Min-heap — every parent ≤ both children. The minimum sits at the root.
- Max-heap — every parent ≥ both children. The maximum sits at the root.
- The rule holds recursively for every node, not just the root.
- Root access is O(1); there is no global left-to-right ordering, only the parent/child relation.