GATE | GATE IT 2006 | Question 71

An array X of n distinct integers is interpreted as a complete binary tree. The index of the first element of the array is 0. The index of the parent of element X[i],i≠0 is?
(A) lowerbound[i/2]
(B) upperbound[(i-1)/2]
(C) upperbound[i/2]
(D) upperbound[i/2] -1

Answer: (D)

Explanation: left child of ith element will be at 2*i+1 and right child at 2(i+1)

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Article Tags :


Please write to us at to report any issue with the above content.