Which one of the following array elements represents a binary min heap?

Category: QuestionsWhich one of the following array elements represents a binary min heap?
Editor">Editor Staff asked 5 months ago

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 Answers
Editor">Editor Staff answered 5 months ago

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.


Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40701