What is the parent for a node ‘w’ of a complete binary tree in an array representation when w is not 0?

Q & ACategory: Data StructureWhat is the parent for a node ‘w’ of a complete binary tree in an array representation when w is not 0?
Admin Staff asked 4 years ago

What is the parent for a node ‘w’ of a complete binary tree in an array representation when w is not 0?
a) floor(w-1/2)
b) ceil(w-1/2)
c) w-1/2
d) w/2

1 Answers
Admin Staff answered 4 years ago

a) floor(w-1/2)