+1 vote
in Data Structures & Algorithms I by (110k points)
If binary trees are represented in arrays, what formula can be used to locate a left child, if the node has an index i?

(a) 2i+1

(b) 2i+2

(c) 2i

(d) 4i

Question is taken from Binary Trees topic in division Binary Trees of Data Structures & Algorithms I

I got this question during an internship interview.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
The correct option is (a) 2i+1

Easiest explanation - If binary trees are represented in arrays, left children are located at indices 2i+1 and right children at 2i+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

...