1.6k views

Consider a binary max-heap implemented using an array.
Which one of the following array represents a binary max-heap?

1. $\left\{25,12,16,13,10,8,14\right\}$
2. $\left\{25,14,13,16,10,8,12\right\}$
3. $\left\{25,14,16,13,10,8,12\right\}$
4. $\left\{25,14,12,13,10,8,16\right\}$
retagged | 1.6k views

The binary max-Heap looks like this :

edited
Taking the given array as level order traversal, we can build binary tree.

(A)  13 comes as child of 12, which is not allowed in a binary max-heap

(B) 16 comes as child of 14 violating max-heap property

(C) is a valid binary max-heap as all children are smaller than their parent

(D) 16 comes as child of 12, violating max-heap property

option c is right

1
2