Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. 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
    1. i - 1


    2. (i + 1)
      2
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.



Your comments will be displayed only after manual approval.