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 1 month 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 1 month 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.