Question 7
Back to Exercise
In a binary heap stored in a 0-based array, where are the children of the node at index i?
- A i + 1 and i + 2
- B 2i and 2i + 1
- C 2i + 1 and 2i + 2 Correct
- D i / 2 and i / 2 + 1
Correct Answer: Option C
The parent of index i is (i − 1) / 2. (2i and 2i + 1 is the 1-based layout.)
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!