+1 vote
in Data Structures & Algorithms I by (88.2k points)
What is the location of a parent node for any arbitary node i?

(a) (i/2) position

(b) (i+1)/ position

(c) floor(i/2) position

(d) ceil(i/2) position

The above asked question is from Binary Heap topic in chapter Heap of Data Structures & Algorithms I

This question was posed to me by my school teacher while I was bunking the class.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
Right choice is (c) floor(i/2) position

The best I can explain: For any node child nodes are located at either 2*i, 2*i +1 So the parent node could be found by taking the floor of the half of child node.

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

...