1.

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/2The query is from Binary Trees in chapter Binary Trees of Data Structures & Algorithms IThis question was addressed to me during an interview for a job.

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.



Discussion

No Comment Found

Related InterviewSolutions