1.

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) positionThe above asked question is from Binary Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me by my school teacher while I was bunking the class.

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.



Discussion

No Comment Found

Related InterviewSolutions