The leaf node for a heap of height h will be at which position.

Category: QuestionsThe leaf node for a heap of height h will be at which position.
Editor">Editor Staff asked 5 months ago

The  leaf node for a heap of height h will be at which position.
 
(a) h
 
(b) h-1
 
(c) h or h-1
 
(d) h-2
 
This key question is from Weak Heap in portion Heap of Data Structures & Algorithms I
 
I had been asked this question during an interview.

1 Answers
Editor">Editor Staff answered 5 months ago

Right option is (c) h or h-1
 
For explanation: A complete binary tree is also a heap so by the property of binary tree the leaf nodes will be must at height h or h-1.


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