-
Consider an array representation of an n element binary heap where the elements are stored from index 1 to index n of the array. For the element stored at index i of the array (i ≤ n), the index of the parent is
-
- i - 1
-
-
-
(i + 1) 2
- i - 1
Correct Option: B
This is a basic question. We know that to reach a node on level i, the distance to the root is i–1. This implies that if an element is stored at index i of the array, then index of the parent is n.