Consider a node R of a complete binary tree
whose value is stored in position i of an array
representation for the tree. If R has a parent,
where will the parent's position be in the array?
\lfloor (i-1)/2 \rfloori+1i+22*i+22*i+1If you have a right sibling, it is at i+1.
If you have a left sibling, it is at i-1.
If you have a right child, it is at 2*i+2.
If you have a left child, it is at 2*i+1.
If you have a parent, it is at \lfloor (i-1)/2 \rfloor.