How it works
Every parent compares correctly against its own children. Siblings are unordered and the structure is not sorted, which is why maintaining it is cheap.
Use a heap when only the extreme element is needed repeatedly.
Common error
Expecting sorted order from a heap traversal. Only the root is guaranteed.
Worked example
Example
Min-heap array: [2, 5, 3, 9, 7]
Parent <= each child
Minimum: root
Siblings are not required to be sortedA binary heap combines a complete-tree shape with a parent-child priority rule. A min-heap exposes the minimum at its root but does not sort every array position.
Exercises
7.1.1 · Explain
Is [1, 4, 3, 9, 8] a valid min-heap in zero-based array order?
Show solution
Yes. The root 1 is at most 4 and 3, and parent 4 is at most 9 and 8. No sibling ordering is required.
7.1.2 · Explain
Why cannot a min-heap generally find an arbitrary target in logarithmic time by a BST-style search?
Show solution
Its ordering is only between a parent and its children, not across entire left and right subtrees. An arbitrary target may require scanning many nodes.
