+1 vote
in Data Structures & Algorithms I by (88.2k points)
Which one of the following array elements represents a binary min heap?

(a) 12 10 8 25 14 17

(b) 8 10 12 25 14 17

(c) 25 17 14 12 10 8

(d) 14 17 25 10 12 8

My enquiry is from Heap topic in section Heap of Data Structures & Algorithms I

This question was posed to me in an interview.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
Right option is (b) 8 10 12 25 14 17

To explain: A tree is min heap when data at every node in the tree is smaller than or equal to it’s children’ s data. So, only 8 10 12 25 14 17 generates required tree.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...