Heap

Order Property

The ordering can be one of two types:

The order property of a heap is a weaker ordering requirement compared to that of a binary search tree. In a max-heap for instance, the value in each node is $\ge$ to the value stored in its children but not necessarily $\ge$ to all its descendants.

Exercise Which of the following are a valid binary (max) heap?

Solution

The two on the top are valid binary (max) heap but the bottom two are not.