retagged by
13,641 views
23 votes
23 votes

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 by

3 Answers

18 votes
18 votes
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
Answer:

Related questions

32 votes
32 votes
4 answers
1
go_editor asked Feb 14, 2015
8,948 views
Consider the following array of elements.$\langle 89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100 \rangle$The minimum number of interchanges needed to convert it into a ma...
27 votes
27 votes
3 answers
2
Kathleen asked Sep 18, 2014
5,595 views
The elements $32, 15, 20, 30, 12, 25, 16,$ are inserted one by one in the given order into a maxHeap. The resultant maxHeap is
24 votes
24 votes
3 answers
3
39 votes
39 votes
5 answers
4
Kathleen asked Sep 22, 2014
43,291 views
What is the maximum height of any AVL-tree with $7$ nodes? Assume that the height of a tree with a single node is $0$.$2$$3$$4$$5$