+1 vote
in Data Structures & Algorithms I by (88.2k points)
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 Answer

+1 vote
by (672k points)
selected by
Best answer
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.

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.