+1 vote
in Data Structures & Algorithms I by (110k points)
Using what formula can a parent node be located in an array?

(a) (i+1)/2

(b) (i-1)/2

(c) i/2

(d) 2i/2

The query is from Binary Trees in chapter Binary Trees of Data Structures & Algorithms I

This question was addressed to me during an interview for a job.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
The correct answer is (b) (i-1)/2

Easy explanation - If a binary tree is represented in an array, parent nodes are found at indices (i-1)/2.

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

...