44.7k views
2 votes
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?

a. 2∗i+2
b. i+1
c. 2∗i+1
d. None of the above

1 Answer

5 votes

Final answer:

The parent of a node R at position i in an array that represents a complete binary tree is located at position ((i-1) / 2), thus the correct answer is 'None of the above'.

Step-by-step explanation:

If we consider a complete binary tree that is represented by an array, and we have a node R at position i, the position of its parent can be determined using a simple mathematical relationship. For any node in a binary tree that is not the root node, its parent node's position can be calculated by taking the index of the current node, subtracting 1, and then dividing by 2. Hence, for a node at position i, the parent's position would be calculated as ((i-1) / 2).

Therefore, the correct answer to the question "Where will the parent's position be in the array for a node R whose position is i?" is None of the above, as none of the provided options match the correct formula for finding the parent of the node in a complete binary tree array representation.

User Bernard Jesop
by
8.7k points