0 votes 0 votes An array X of n distinct integers is interpreted as a complete binary tree.The index of first element of array is 0.index of parent of element X[i] is (i-2)/2 (i/2)-1 A_i_$_h asked Jun 14, 2017 A_i_$_h 419 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 0 votes 0 votes if index of first element of array is 0 then left child of ith element will be at 2*i+1 and right child at 2(i+1) so index of parent of element X[i] is ⌈i2⌉−1 otherwise take one example and verify it pawan kumarln answered Jun 14, 2017 selected Aug 7, 2017 by pawan kumarln pawan kumarln comment Share Follow See all 3 Comments See all 3 3 Comments reply A_i_$_h commented Jun 14, 2017 reply Follow Share What if the index of first element is 1 then what is the index of left Nd right child? 0 votes 0 votes pawan kumarln commented Jun 16, 2017 reply Follow Share 2i and 2i+1 respectively 1 votes 1 votes A_i_$_h commented Jun 16, 2017 reply Follow Share thank you :) 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes i think answer should be (i/2) -1 we should take upper bound of (i/2) Kaluti answered Jun 14, 2017 Kaluti comment Share Follow See all 0 reply Please log in or register to add a comment.